/* Karunguru+ theme compatibility.
 *
 * Not part of the design system, and not generated: this is the layer that
 * gets a stock WordPress theme out of the way so the design system can do its
 * job. It loads last, after the theme, which is the only reason it wins.
 *
 * Two jobs.
 *
 * 1. Hide the theme's header and footer. The site renders its own, from the
 *    plugin, so it keeps its chrome whatever happens to the theme.
 *
 * 2. Unwrap the content. A block theme puts post content inside a container
 *    about 650px wide and gives every direct child that same max-width. Our
 *    sections are full bleed by design, so inside that container the entire
 *    site renders as a narrow column. This undoes the constraint rather than
 *    fighting it with viewport-width breakout rules, which bring their own
 *    horizontal-scroll problems once a scrollbar is present.
 *
 * It touches nothing outside pages this plugin installed, except the theme
 * chrome, which is hidden sitewide so the brand header is the only one. No
 * theme file is modified: deactivate the plugin and the theme is as it was.
 */

/* ------------------------------------------------------------ 0. typography */
/* The one that mattered most on the live site.
 *
 * Hello Elementor's reset.css sets `body` to the system font stack and
 * `h1` to `h6` to `font-family: inherit`, and it loads after the design system.
 * Same specificity, later in the cascade, so it won. The result was the whole
 * site rendering in system sans while Fraunces and DM Sans sat downloaded and
 * unused. Elementor's global kit then layers its own Roboto on top.
 *
 * This file loads last, so restating the two families here is what makes them
 * stick. It is deliberately blunt: a theme reset is blunt too.
 */
body.kps-chrome,
body.kps-chrome button,
body.kps-chrome input,
body.kps-chrome select,
body.kps-chrome textarea {
	font-family: 'DM Sans', system-ui, sans-serif !important;
}

body.kps-chrome h1, body.kps-chrome h2,
body.kps-chrome h3, body.kps-chrome h4,
body.kps-chrome .h1, body.kps-chrome .h2,
body.kps-chrome .h3, body.kps-chrome .h4,
body.kps-chrome .display,
body.kps-chrome .price,
body.kps-chrome .quote p {
	font-family: 'Fraunces', Georgia, serif !important;
}

/*
 * Nothing on this site is underlined.
 *
 * The design system has said `a { text-decoration: none }` from the first
 * build, and it was still losing, for exactly the reason the fonts were:
 * Hello Elementor's reset underlines links at equal specificity and loads
 * afterwards. So the rule has to be restated here, in the file that loads
 * last, or it is a rule in a file nobody reads.
 *
 * `:where()` on the selector would be neater and would also be weaker, which
 * is the whole problem. The state selectors are listed because a reset that
 * only underlines on hover still underlines.
 */
body.kps-chrome a,
body.kps-chrome a:link,
body.kps-chrome a:visited,
body.kps-chrome a:hover,
body.kps-chrome a:focus,
body.kps-chrome a:active,
body.kps-chrome button,
body.kps-chrome .b,
body.kps-chrome .lk,
body.kps-chrome .rm,
body.kps-chrome summary {
	text-decoration: none !important;
}

/* Elementor's kit points its global typography variables at Roboto, which it
   then applies through its own classes. Repointing the variables is cleaner
   than chasing every selector that reads them. */
body.kps-chrome {
	--e-global-typography-primary-font-family: 'Fraunces';
	--e-global-typography-secondary-font-family: 'Fraunces';
	--e-global-typography-text-font-family: 'DM Sans';
	--e-global-typography-accent-font-family: 'DM Sans';
}

/* ---------------------------------------------------------------- 1. chrome */
/* Block themes: the header and footer are template parts, direct children of
   the site blocks wrapper. */
body.kps-chrome .wp-site-blocks > header,
body.kps-chrome .wp-site-blocks > footer,
body.kps-chrome > .wp-site-blocks > header.wp-block-template-part,
body.kps-chrome > .wp-site-blocks > footer.wp-block-template-part,
/* Classic themes keep to these names. */
body.kps-chrome > #masthead,
body.kps-chrome > #colophon,
body.kps-chrome > .site-header,
body.kps-chrome > .site-footer,
body.kps-chrome > header.site-header,
body.kps-chrome > footer.site-footer,
body.kps-chrome .wp-block-template-part > .wp-block-navigation,
body.kps-chrome .skip-link {
	display: none !important;
}

/* Our own header and footer are printed straight into the body, so they must
   not inherit a theme container's width or spacing. */
body.kps-chrome > .strip,
body.kps-chrome > .hdr,
body.kps-chrome > .ft {
	max-width: none !important;
	width: auto !important;
	margin: 0 !important;
}

/* ---------------------------------------------------------------- 2. unwrap */
body.kps-page {
	margin: 0 !important;
	padding: 0 !important;
}

body.kps-page .wp-site-blocks,
body.kps-page .wp-site-blocks > main,
body.kps-page main.wp-block-group,
body.kps-page .wp-block-post-content,
body.kps-page .entry-content,
body.kps-page .site-main,
body.kps-page #primary,
body.kps-page #content,
body.kps-page article.page,
body.kps-page article.post {
	max-width: none !important;
	width: auto !important;
	margin-left: 0 !important;
	margin-right: 0 !important;
	padding-left: 0 !important;
	padding-right: 0 !important;
}

/* The rule that actually narrows everything: a constrained layout gives each
   direct child the theme's content width. Our sections set their own. */
body.kps-page .is-layout-constrained > *,
body.kps-page .wp-block-post-content > *,
body.kps-page .entry-content > * {
	max-width: none !important;
	margin-left: 0 !important;
	margin-right: 0 !important;
}

/* Block themes space every sibling apart. Our sections carry their own
   rhythm, so the extra gap only opens holes between bands. */
body.kps-page .wp-block-post-content > * + *,
body.kps-page .entry-content > * + * {
	margin-block-start: 0 !important;
}

/* Some themes print the page title above the content. Ours is in the design. */
body.kps-page .wp-block-post-title,
body.kps-page .entry-header,
body.kps-page .page-header {
	display: none !important;
}

/* The theme sets a root background and text colour that show through between
   our bands. */
body.kps-page {
	background: #F7F3EC !important;
}

/* ---------------------------------------------------------------- 3. sticky */
/* A transform, filter or contain on an ancestor turns position:sticky into
   position:relative, which silently kills the sticky header. */
body.kps-chrome .wp-site-blocks,
body.kps-chrome .wp-site-blocks > main {
	transform: none !important;
	filter: none !important;
	contain: none !important;
	overflow: visible !important;
}

/* The admin bar is fixed at the top for logged-in users, so the sticky header
   has to start below it rather than underneath. */
body.admin-bar.kps-chrome .hdr {
	top: 32px;
}

@media screen and (max-width: 782px) {
	body.admin-bar.kps-chrome .hdr {
		top: 46px;
	}
}


/*
 * Block themes wrap the content in groups that carry their own padding and
 * margin, which on a page that renders its own full width bands opens a
 * 140px hole between the header and the first band. The site is built to
 * survive a theme change, so the wrappers are neutralised here rather than
 * relying on the theme in use today.
 */
body.kps-chrome .wp-block-group.has-global-padding,
body.kps-chrome .wp-block-group.alignfull,
body.kps-chrome .wp-site-blocks,
body.kps-chrome .entry-content,
body.kps-chrome .site-content,
body.kps-chrome main.wp-block-group {
	margin-block-start: 0 !important;
	margin-top: 0 !important;
	padding-top: 0 !important;
	max-width: none !important;
}

/*
 * The side padding is left alone deliberately. Clearing it too took the
 * gutter off the article page on a phone and pushed the text thirty pixels
 * off the left edge. Only the vertical space and the width cap are the
 * theme's to lose here.
 */

/* The byline and post meta a theme prints above a product or a page. The
   shop block and each page carry their own heading and their own meta. */
body.kps-chrome.single-shc_product .entry-meta,
body.kps-chrome.single-shc_product .post-meta,
body.kps-chrome.single-shc_product .wp-block-post-author,
body.kps-chrome.single-shc_product .wp-block-post-date,
body.kps-chrome.single-shc_product .wp-block-post-terms {
	display: none !important;
}

/* ------------------------------------------------------ 4. controls and links */
/*
 * The third time this exact fault has shipped, and the reason it keeps
 * shipping is that we test our stylesheets without the theme in front of
 * them.
 *
 * Hello Elementor's reset.css carries this:
 *
 *   [type="button"], [type="submit"], button {
 *     background-color: transparent; border: 1px solid #CC3366;
 *     border-radius: 3px; color: #CC3366; padding: 0.5rem 1rem;
 *   }
 *   a { color: #CC3366 }
 *
 * `[type="submit"]` is one class worth of specificity, exactly the same as
 * `.shc-button--primary`, and reset.css loads after the design system. At a
 * tie the later sheet wins, so every button on the shop rendered as a pink
 * outline box with a three pixel radius at thirty four pixels tall, and every
 * link without a class of its own rendered #CC3366. On the near black footer
 * that was red text failing contrast; on the product page it was the primary
 * conversion control looking like a disabled secondary.
 *
 * #CC3366 is not in the Karunguru palette. It is the theme's default.
 *
 * The fix is specificity rather than ordering, because ordering is what we
 * lost last time: `body.kps-chrome .shc-button` is two classes and an
 * element, which no bare element or attribute selector can reach. The values
 * restate the design system rather than inventing anything, so shupcommerce
 * .css stays the place the design lives.
 */
/*
 * Buttons are excluded, and that exclusion is the whole point of the rule.
 *
 * The first version of this was `body.kps-chrome a:link`, which looked
 * narrower than `.b.ghost` and is not: `:link` is a pseudo class and counts
 * in the class column, so the selector scores two classes and two elements
 * against the ghost button's two classes and nothing. It won, and the hero's
 * secondary button lost its Warm White label to whatever the hero inherited,
 * which on a dark photograph is a button you cannot read.
 *
 * A link that is dressed as a button already has its colour decided.
 */
body.kps-chrome a:not(.b):not(.shc-button),
body.kps-chrome a:not(.b):not(.shc-button):link,
body.kps-chrome a:not(.b):not(.shc-button):visited {
	color: inherit;
}

body.kps-chrome .shc-button,
body.kps-chrome button.shc-button,
body.kps-chrome [type="submit"].shc-button,
body.kps-chrome [type="button"].shc-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 44px;
	border: 1.5px solid transparent;
	border-radius: 999px;
	padding: 17px 30px;
	font-family: 'DM Sans', system-ui, sans-serif;
	font-size: 17px;
	font-weight: 600;
	line-height: 1;
	background-color: transparent;
	color: #121212;
	cursor: pointer;
}

body.kps-chrome .shc-button--primary,
body.kps-chrome button.shc-button--primary,
body.kps-chrome [type="submit"].shc-button--primary {
	background-color: #17A06A;
	border-color: #17A06A;
	color: #121212;
}

body.kps-chrome .shc-button--primary:hover,
body.kps-chrome .shc-button--primary:focus,
body.kps-chrome button.shc-button--primary:hover,
body.kps-chrome [type="submit"].shc-button--primary:hover {
	background-color: #0B6B47;
	border-color: #0B6B47;
	color: #F6F1E9;
}

body.kps-chrome .shc-button--secondary,
body.kps-chrome button.shc-button--secondary {
	background-color: transparent;
	border-color: #DDD5C7;
	color: #121212;
}

body.kps-chrome .shc-button--secondary:hover,
body.kps-chrome button.shc-button--secondary:hover {
	border-color: #121212;
}

/* The quiet actions: remove a line, step back, update a basket. They stay
   quiet, and they still clear forty four pixels, because a thumb does not
   care how important we think a control is. */
body.kps-chrome .shc-button--tertiary,
body.kps-chrome .shc-button--remove,
body.kps-chrome button.shc-button--tertiary,
body.kps-chrome button.shc-button--remove {
	background-color: transparent;
	border-color: transparent;
	color: #696865;
	padding: 12px 22px;
	font-size: 14px;
	min-height: 44px;
}

body.kps-chrome .shc-button--tertiary:hover,
body.kps-chrome .shc-button--remove:hover,
body.kps-chrome button.shc-button--tertiary:hover,
body.kps-chrome button.shc-button--remove:hover {
	color: #121212;
}

body.kps-chrome .shc-button:focus-visible {
	outline: 3px solid #17A06A;
	outline-offset: 2px;
}

body.kps-chrome .shc-button[disabled],
body.kps-chrome .shc-button[aria-disabled="true"] {
	opacity: .5;
	cursor: not-allowed;
}

/* ------------------------------------------------------------- 5. tables */
/*
 * The basket arrived looking like a spreadsheet, and the reason was not our
 * stylesheet. Hello Elementor's reset carries:
 *
 *   table td, table th { border: 1px solid rgba(128,128,128,.5); padding: 15px }
 *   table tbody > tr:nth-child(2n+1) > td { background-color: rgba(128,128,128,.07) }
 *   table { font-size: 0.9em }
 *
 * Our cell rule is a class, so it beat the theme on padding and on the bottom
 * border. It never set the other three borders, so those were drawn, which is
 * where the ruled grid came from. The zebra stripe is worse: one pseudo class
 * and three elements outranks a single class outright, so every other row was
 * shaded grey no matter what the design system said.
 *
 * Neutralised here, scoped to our own tables, so a table somebody writes into
 * a post still gets the theme's styling.
 */
body.kps-chrome .shc-cart__table,
body.kps-chrome .shc-order__table {
	font-size: 1rem;
	margin-block-end: 0;
}

body.kps-chrome .shc-cart__table td,
body.kps-chrome .shc-cart__table th,
body.kps-chrome .shc-order__table td,
body.kps-chrome .shc-order__table th {
	border-left: 0;
	border-right: 0;
	border-top: 0;
}

body.kps-chrome .shc-cart__table tbody > tr > td,
body.kps-chrome .shc-cart__table tbody > tr > th,
body.kps-chrome .shc-cart__table tbody > tr:nth-child(2n+1) > td,
body.kps-chrome .shc-cart__table tbody > tr:nth-child(2n+1) > th,
body.kps-chrome .shc-cart__table tbody tr:hover > td,
body.kps-chrome .shc-cart__table tbody tr:hover > th,
body.kps-chrome .shc-order__table tbody > tr > td,
body.kps-chrome .shc-order__table tbody > tr:nth-child(2n+1) > td,
body.kps-chrome .shc-order__table tbody tr:hover > td {
	background-color: transparent;
}
