/*
 * Design tokens, loaded first on every surface: the main site (inc/_core/headFiles.php),
 * Weave (templates/weave/base.html.twig) and wx-admin (wx-admin/inc/_core/headFiles.php).
 *
 * Only custom properties belong here, no selectors that style anything.
 * See docs/design-system/README.md.
 */

/*
 * Brand palette, from the Peters brand guidelines (docs/design-system/brand-guidelines.md).
 * The guidelines call jade "Green" and green "Light green"; the tints match the names used here.
 * Grey and light grey aren't brand colours.
 */
:root {
	--peters-blue: #2995D3;
	--peters-blue-rgb: 41, 149, 211;

	--peters-light-blue: #E9F4FA;
	--peters-light-blue-rgb: 233, 244, 250;

	/*
	 * Website additions (November 2026): darker shades of brand colours, each dark enough for white
	 * text on it (5:1 or more) and to be text on its own tint (4.5:1 or more). Used where the header,
	 * footer and menu used the brand colour itself, which fails contrast there.
	 */
	--peters-dark-blue: #2074A5;
	--peters-dark-blue-rgb: 32, 116, 165;

	--peters-steel: #28527C;
	--peters-steel-rgb: 40, 82, 124;

	--peters-soft-red: #E15554;
	--peters-soft-red-rgb: 225, 85, 84;

	--peters-purple: #5c4293;
	--peters-purple-rgb: 92, 66, 147;

	--peters-light-purple: #edeaf3;
	--peters-light-purple-rgb: 237, 234, 243;

	--peters-jade: #079285;
	--peters-jade-rgb: 7, 146, 133;

	--peters-light-jade: #e3f3f2;
	--peters-light-jade-rgb: 227, 243, 242;

	/* Website addition (November 2026), as dark blue above; also furniture pages' fills */
	--peters-dark-jade: #06756A;
	--peters-dark-jade-rgb: 6, 117, 106;

	--peters-yellow: #F8AF14;
	--peters-yellow-rgb: 248, 175, 20;

	--peters-light-yellow: #FEF2D8;
	--peters-light-yellow-rgb: 254, 242, 216;

	/* Website addition (November 2026), as dark blue above */
	--peters-dark-yellow: #92670C;
	--peters-dark-yellow-rgb: 146, 103, 12;

	--peters-green: #80b349;
	--peters-green-rgb: 128, 179, 73;

	--peters-light-green: #f1f7eb;
	--peters-light-green-rgb: 241, 247, 235;

	/* Website addition (November 2026), as dark blue above */
	--peters-dark-green: #577A32;
	--peters-dark-green-rgb: 87, 122, 50;

	--peters-pink: #DA1E63;
	--peters-pink-rgb: 218, 30, 99;

	--peters-light-pink: #FEE2EE;
	--peters-light-pink-rgb: 254, 226, 238;

	/* Website addition (November 2026), as dark blue above */
	--peters-dark-pink: #C91C5B;
	--peters-dark-pink-rgb: 201, 28, 91;

	--peters-navy: #1c2542;
	--peters-navy-rgb: 28, 37, 66;

	--peters-grey: #d6d6d6;
	--peters-grey-rgb: 214, 214, 214;

	--peters-light-grey: #F2F2F2;
	--peters-light-grey-rgb: 242, 242, 242;
}

/*
 * Website additions to the brand palette, for status messages only.
 * Errors and success use a standard red and green rather than soft red and jade,
 * so they read as warnings and confirmations, not as brand colours. Both carry
 * small text on white and on their tints. To be added to the brand guidelines.
 */
:root {
	--status-red: #C62828;
	--status-light-red: #FDECEA;
	--status-green: #2E7D32;
	--status-light-green: #EDF7EE;
}

/*
 * Design system tokens (2027 facelift), agreed in docs/design-system/proposal.md.
 * Components (components.css) use these, never the palette above directly.
 * px, not rem: Weave's root font size differs from the main site's.
 *
 * The colours here are the light theme. [data-theme="dark"] below restates every colour token
 * for the dark theme: a token that refers to another (var(--grey-600)) is resolved where it's
 * declared, so changing only the greys wouldn't reach it. Add any new colour token to both.
 */
:root,
[data-theme="light"] {
	color-scheme: light;

	/* Greys */
	--grey-50: #F5F5F5;
	--grey-100: #ECECEC;
	--grey-200: #D6D6D6;
	--grey-300: #CACACA;
	--grey-500: #8A8A8A;
	--grey-600: #666666;
	--grey-800: #4A4A4A;
	--grey-900: #2D2D2D;

	/* Colour roles */
	--color-text: var(--peters-navy);
	--color-text-muted: var(--grey-600);
	--color-primary: var(--peters-steel);
	--color-primary-hover: var(--peters-navy);
	--color-accent: var(--peters-pink);
	--color-on-primary: #FFFFFF; /* text on primary, danger and selected fills */
	--color-on-accent: #FFFFFF;
	--color-title: var(--peters-blue);
	--color-bg: #FFFFFF;
	--color-bg-subtle: var(--grey-50);
	--color-bg-highlight: var(--peters-light-blue);
	--color-surface: #FFFFFF; /* fields, modals, dropdown lists */
	--color-overlay: rgba(var(--peters-navy-rgb), 0.5);
	--color-border: var(--grey-300);
	--color-border-subtle: var(--grey-100);
	--color-border-field: var(--grey-500);

	/* Status: the colour is for borders and icons; error and success colours can also carry text */
	--color-success: var(--status-green);
	--color-success-bg: var(--status-light-green);
	--color-warning: var(--peters-yellow);
	--color-warning-bg: var(--peters-light-yellow);
	--color-error: var(--status-red);
	--color-error-bg: var(--status-light-red);
	--color-info: var(--peters-blue);
	--color-info-bg: var(--peters-light-blue);

	/*
	 * Section colours: the colour-coded parts of the header and footer (menu tabs and their dropdowns,
	 * the account bar, footer headings). Text in a section colour, its tint as a background, and its
	 * fill (the menu's hover chips). In light these are the palette colours the header already used;
	 * in dark, lighter shades of the brand colours on dark tints (see README.md#dark-mode).
	 */
	--color-section-blue: var(--peters-dark-blue);
	--color-section-blue-bg: var(--peters-light-blue);
	--color-section-blue-fill: var(--peters-blue);
	--color-section-purple: var(--peters-purple);
	--color-section-purple-bg: var(--peters-light-purple);
	--color-section-purple-fill: var(--peters-purple);
	--color-section-jade: var(--peters-dark-jade);
	--color-section-jade-bg: var(--peters-light-jade);
	--color-section-jade-fill: var(--peters-jade);
	--color-section-yellow: var(--peters-dark-yellow);
	--color-section-yellow-bg: var(--peters-light-yellow);
	--color-section-yellow-fill: var(--peters-yellow);
	--color-section-green: var(--peters-dark-green);
	--color-section-green-bg: var(--peters-light-green);
	--color-section-green-fill: var(--peters-green);
	--color-section-pink: var(--peters-dark-pink);
	--color-section-pink-bg: var(--peters-light-pink);
	--color-section-pink-fill: var(--peters-pink);
	/* Pink text: the account bar's links and menu, carousels' offers and special offers headings */
	--color-text-pink: var(--peters-pink);
	/* Furniture pages' fills in the header (search, basket, drawer), with --color-on-primary text on them */
	--color-furniture: var(--peters-dark-jade);
	/* The legacy CSS's grey drop shadow (4px 4px 3px 1px), still on the header's panels and buttons */
	--color-legacy-shadow: rgba(168, 168, 168, .5);
	/* Behind logos and other images drawn for a white background, where they sit on a dark one */
	--color-image-panel: #FFFFFF;
	/* The legacy darker grey behind table rows and boxes that carry links (the book page's editions,
	   libraries' ordering grid); in dark, a step above --grey-100 that links still read on (5.2:1) */
	--color-bg-strong: #C9C9C9;
	/*
	 * Chart series (the reports dashboard, components/dashboard.js), in this order round a pie. Light: the brand
	 * colours. Dark: each pair that touches keeps a lightness gap (blue above purple, jade above pink and grey),
	 * so they stay apart with colour blindness, and each is 3:1 or more on the page. Not approved by Marketing as
	 * chart colours (see README.md#dark-mode). Charts read them with useChartColours() (helpers.mjs).
	 */
	--color-chart-blue: var(--peters-blue);
	--color-chart-purple: var(--peters-purple);
	--color-chart-yellow: var(--peters-yellow);
	--color-chart-pink: var(--peters-pink);
	--color-chart-jade: var(--peters-jade);
	--color-chart-grey: #ABABAB;

	/* Dropdown chevron, drawn in the text colour */
	--icon-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%231C2542' stroke-width='2'/%3E%3C/svg%3E");

	/* Typography */
	--font-family: 'Open Sans', sans-serif;
	--font-weight-light: 300;
	--font-weight-regular: 400;
	--font-weight-semibold: 600;
	--font-weight-bold: 700;
	--font-size-xs: 12px;
	--font-size-sm: 14px;
	--font-size-md: 16px;
	--font-size-lg: 18px;
	--font-size-xl: 20px;
	--font-size-2xl: 24px;
	--font-size-3xl: 30px;
	--font-size-4xl: 40px;
	--line-height-body: 1.4;
	--line-height-heading: 1.2;

	/* Spacing */
	--space-1: 5px;
	--space-2: 10px;
	--space-3: 15px;
	--space-4: 20px;
	--space-5: 30px;
	--space-6: 40px;
	--space-7: 60px;
	--space-8: 80px;

	/* Corners, shadows and focus */
	--radius-sm: 4px;
	--radius-md: 8px;
	--radius-full: 9999px;
	--shadow-sm: 0 1px 3px rgba(var(--peters-navy-rgb), 0.15);
	--shadow-md: 0 3px 8px rgba(var(--peters-navy-rgb), 0.2);
	--focus-ring: 2px solid var(--peters-steel);
	--focus-ring-offset: 2px;
}

/*
 * Dark theme (approved November 2026, see docs/design-system/proposal.md#dark-mode), on <html> or on any element
 * (the /style-guide preview). Built on the brand navy, with a light Peters blue as the primary
 * colour: steel is too dark to read on navy, and Peters blue itself is dull on it. Contrast on the
 * page background: text 15.6:1, muted text 8.6:1, links, primary buttons and page titles 8.2:1
 * (6.6:1 on surfaces), field borders 5.9:1, panel borders 2.6:1, errors 7.4:1.
 */
[data-theme="dark"] {
	color-scheme: dark;

	/* Greys, reversed so lower numbers stay closest to the background */
	--grey-50: #1C2440;
	--grey-100: #2A3352;
	--grey-200: #3A4466;
	--grey-300: #4E5A80;
	--grey-500: #8A94B4;
	--grey-600: #AEB5C8;
	--grey-800: #D5D9E4;
	--grey-900: #EEF1F7;

	/* Colour roles */
	--color-text: #EEF1F7;
	--color-text-muted: #AEB5C8;
	--color-primary: #6BB9E8;
	--color-primary-hover: #A6D6F4;
	--color-accent: var(--peters-pink);
	--color-on-primary: #121829;
	--color-on-accent: #FFFFFF;
	--color-title: #6BB9E8;
	--color-bg: #121829;
	--color-bg-subtle: #1C2440;
	--color-bg-highlight: #1F4470;
	--color-surface: #1F2948;
	--color-overlay: rgba(0, 0, 0, 0.6);
	--color-border: #4E5A80;
	--color-border-subtle: #3A4466;
	--color-border-field: #8A94B4;

	/* Status */
	--color-success: #81C995;
	--color-success-bg: #183223;
	--color-warning: var(--peters-yellow);
	--color-warning-bg: #3A2F12;
	--color-error: #F28B82;
	--color-error-bg: #3A1D22;
	--color-info: #8CC6EA;
	--color-info-bg: #16304A;

	/* Section colours (November 2026, to be shown to Marketing): lighter shades of the brand colours,
	   each 4.8:1 or more on surfaces, on 20% tints of the brand colour over the page (jade 16%, so
	   its text stays above 4.5:1). Text on its tint: blue 6.2, purple 5.3, jade 4.7, yellow 6.3,
	   green 5.0, pink 5.1. The fill is the text colour, with the tint on it. */
	--color-section-blue: #6BB9E8;
	--color-section-blue-bg: #17314B;
	--color-section-blue-fill: #6BB9E8;
	--color-section-purple: #9D8EBE;
	--color-section-purple-bg: #21203E;
	--color-section-purple-fill: #9D8EBE;
	--color-section-jade: #2CA297;
	--color-section-jade-bg: #102C38;
	--color-section-jade-fill: #2CA297;
	--color-section-yellow: var(--peters-yellow);
	--color-section-yellow-bg: #403625;
	--color-section-yellow-fill: var(--peters-yellow);
	--color-section-green: var(--peters-green);
	--color-section-green-bg: #28372F;
	--color-section-green-fill: var(--peters-green);
	--color-section-pink: #E76D9A;
	--color-section-pink-bg: #3A1935;
	--color-section-pink-fill: #E76D9A;
	--color-text-pink: #E76D9A;
	--color-furniture: #2CA297; /* navy text on it 5.4:1 */
	--color-legacy-shadow: rgba(0, 0, 0, .5);
	--color-image-panel: #FFFFFF;
	--color-bg-strong: #303A5B;
	/* On the page: 8.1:1, 3.5:1, 9.4:1, 3.7:1, 6.9:1, 3.6:1 */
	--color-chart-blue: #53B8F8;
	--color-chart-purple: #7960B4;
	--color-chart-yellow: var(--peters-yellow);
	--color-chart-pink: var(--peters-pink);
	--color-chart-jade: #41B3A5;
	--color-chart-grey: #717171;

	--icon-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23EEF1F7' stroke-width='2'/%3E%3C/svg%3E");

	--shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
	--shadow-md: 0 3px 8px rgba(0, 0, 0, 0.5);
	--focus-ring: 2px solid #A6D6F4;
}
