/*
 * Allergy Buddy — design system (tokens + component classes).
 * Mapped from BRAND.md §7. theme.json is the single source of truth for the
 * palette, fonts, sizes and weights — it emits --wp--preset--*/--wp--custom--*
 * which the brand tokens below (--bg, --ink, --red, …) alias, so the .ds-*
 * components, the html-to-generateblocks "design-system mode", the block editor
 * swatches and GeneratePress's palette all resolve to the same values. Change a
 * colour or size in theme.json, not here.
 *
 * Brand rules baked in:
 *  - Red (--red) is the only interactive brand colour: primary CTA, alerts.
 *  - Blue / green / gold are RESERVED for the pouch-stripe motif + medical-alert
 *    headers — never buttons or links.
 *  - Headings: DM Sans 500, tight tracking, balanced wrap. Body: DM Sans 16/1.55.
 *  - Eyebrows / metadata: DM Mono, uppercase, wide tracking.
 *  - Hairline 1px borders, 14px card radius, pill buttons, no drop shadows.
 */

/* ============================================================ FONTS (self-hosted)
 * Drop the woff2 files into assets/fonts/ (DM Sans + DM Mono). Until then the
 * fallbacks render. Self-hosted on purpose — no Google Fonts (privacy + speed).
 */
@font-face {
	font-family: "DM Sans";
	font-style: normal;
	font-weight: 400 700;
	font-display: swap;
	src: url("../fonts/dm-sans.woff2") format("woff2");
}
@font-face {
	font-family: "DM Mono";
	font-style: normal;
	font-weight: 400;
	font-display: swap;
	src: url("../fonts/dm-mono-400.woff2") format("woff2");
}
@font-face {
	font-family: "DM Mono";
	font-style: normal;
	font-weight: 500;
	font-display: swap;
	src: url("../fonts/dm-mono-500.woff2") format("woff2");
}

/* ============================================================ TOKENS */
:root {
	/* --- Brand palette (BRAND.md §7.1) — values live in theme.json --- */
	--bg: var(--wp--preset--color--bg);          /* page background — paper */
	--bg-2: var(--wp--preset--color--bg-2);      /* section accent (deeper paper) */
	--paper: var(--wp--preset--color--paper);    /* card / panel surfaces */
	--ink: var(--wp--preset--color--ink);        /* primary text, dark sections, primary buttons */
	--ink-2: var(--wp--preset--color--ink-2);    /* secondary text */
	--ink-3: var(--wp--preset--color--ink-3);    /* tertiary text, mono labels */
	--line: var(--wp--preset--color--line);      /* hairline borders */
	--line-2: var(--wp--preset--color--line-2);  /* stronger borders */
	--red: var(--wp--preset--color--red);        /* logo red — primary CTA, alerts ONLY */
	--red-deep: var(--wp--preset--color--red-deep); /* red hover */
	--red-soft: #F1DDD9;                          /* red wash (derived tint, not an editor swatch) */
	--blue: var(--wp--preset--color--blue);      /* logo blue — pouch stripe only */
	--green: var(--wp--preset--color--green);    /* logo green — pouch stripe only */
	--gold: var(--wp--preset--color--gold);      /* logo gold — pouch stripe only */

	/* --- Type (families live in theme.json) --- */
	--font-sans: var(--wp--preset--font-family--sans);
	--font-mono: var(--wp--preset--font-family--mono);

	/*
	 * Homepage tokens. GenerateBlocks stored this set in the database
	 * (generateblocks_style_css) and wrote it to uploads/generateblocks/.
	 * The theme copy does not include that file, so the values live here.
	 * Line and ink-3 differ from the theme.json presets on purpose: this is
	 * the set the homepage was rendered with.
	 */
	--ab-ink: #14181D;
	--ab-ink-2: #4D535D;
	--ab-ink-3: #8A909A;
	--ab-bg: #F8F6F1;
	--ab-bg-2: #EFEDE5;
	--ab-paper: #FDFCFA;
	--ab-line: #E3DFD4;
	--ab-line-2: #CFC9BB;
	--ab-red: #B9322A;
	--ab-red-deep: #7A1E18;
	--ab-red-soft: #F1DDD9;
	--ab-blue: #2A4A8A;
	--ab-green: #3F7A44;
	--ab-gold: #C98A2C;
	--ab-hero-ground: #E7E2DD;
	--ab-white: #FFFFFF;
	--ab-content: 1200px;
	--ab-section: 84px;
	--ab-radius: 14px;
	--ab-heading: clamp(30px, 4vw, 46px);
	--ab-hero-title: clamp(30px, 4.2vw, 48px);
	--ab-hero-photo: min(720px, calc(100vh - 220px));
	--ab-sans: "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	--ab-mono: "DM Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

	/* --- ds-* aliases (used by components + the conversion skill) --- */
	--ds-primary: var(--red);
	--ds-primary-dark: var(--red-deep);
	--ds-accent: var(--red);
	--ds-ink: var(--ink);
	--ds-body: var(--ink);
	--ds-muted: var(--ink-2);
	--ds-bg: var(--bg);
	--ds-surface: var(--paper);
	--ds-surface-2: var(--bg-2);
	--ds-border: var(--line);
	--ds-border-strong: var(--line-2);
	--ds-inverse: var(--ink);
	--ds-inverse-text: var(--paper);

	--ds-font-head: var(--font-sans);
	--ds-font-body: var(--font-sans);
	--ds-font-mono: var(--font-mono);
	--ds-text-xs: var(--wp--preset--font-size--xs);     /* ~11px — eyebrows */
	--ds-text-sm: var(--wp--preset--font-size--sm);     /* 14px */
	--ds-text-base: var(--wp--preset--font-size--base); /* 16px body */
	--ds-text-lg: var(--wp--preset--font-size--lg);
	--ds-text-xl: var(--wp--preset--font-size--xl);
	--ds-text-2xl: var(--wp--preset--font-size--2-xl);
	--ds-text-3xl: var(--wp--preset--font-size--3-xl);
	--ds-text-display: var(--wp--preset--font-size--display);
	--ds-leading-tight: var(--wp--custom--line-height--tight);
	--ds-leading: var(--wp--custom--line-height--base);
	--ds-tracking-head: var(--wp--custom--letter-spacing--head);
	--ds-tracking-eyebrow: var(--wp--custom--letter-spacing--eyebrow);
	--ds-weight-normal: var(--wp--custom--font-weight--normal);
	--ds-weight-medium: var(--wp--custom--font-weight--medium);
	--ds-weight-semibold: var(--wp--custom--font-weight--semibold);
	--ds-weight-bold: var(--wp--custom--font-weight--bold);
	/* headings use 500 per brand — kept as an explicit token */
	--ds-weight-head: var(--wp--custom--font-weight--head);

	/* --- Spacing (sections breathe at 96 / 72; 7 steps live in theme.json) --- */
	--ds-space-3xs: 0.25rem;  /* below the editor scale — stays literal */
	--ds-space-2xs: 0.5rem;   /* below the editor scale — stays literal */
	--ds-space-xs: var(--wp--preset--spacing--20);
	--ds-space-sm: var(--wp--preset--spacing--30);
	--ds-space-md: var(--wp--preset--spacing--40);
	--ds-space-lg: var(--wp--preset--spacing--50);
	--ds-space-xl: var(--wp--preset--spacing--60);
	--ds-space-2xl: var(--wp--preset--spacing--70);   /* 72px */
	--ds-space-3xl: var(--wp--preset--spacing--80);   /* 96px */

	/* --- Radius / layout --- */
	--ds-radius-sm: 0.5rem;
	--ds-radius: 0.875rem;    /* 14px cards/surfaces */
	--ds-radius-lg: 1.25rem;
	--ds-radius-full: 999px;  /* pill buttons */
	--ds-container: 1100px;
	--ds-container-wide: 1280px;
	--ds-measure: 60ch;       /* body max line length */
	--ds-transition: 0.2s ease;
}

/* ============================================================ BASE */
body {
	background-color: var(--bg);
	color: var(--ink);
	font-family: var(--font-sans);
	font-size: var(--ds-text-base);
	line-height: var(--ds-leading);
}
h1, h2, h3, h4 {
	font-family: var(--font-sans);
	font-weight: var(--ds-weight-head);
	letter-spacing: var(--ds-tracking-head);
	line-height: var(--ds-leading-tight);
	color: var(--ink);
}
h1, h2 { text-wrap: balance; }
a { color: var(--red); }
a:hover { color: var(--red-deep); }

/* ============================================================ LAYOUT */
.ds-section { padding-block: clamp(3rem, 8vw, var(--ds-space-3xl)); padding-inline: var(--ds-space-md); }
.ds-section--tight { padding-block: clamp(2.5rem, 6vw, var(--ds-space-2xl)); }
.ds-section--accent { background: var(--bg-2); }
.ds-section--dark { background: var(--ink); color: var(--paper); }
.ds-section--dark h1, .ds-section--dark h2, .ds-section--dark h3,
.ds-section--dark .ds-h2, .ds-section--dark .ds-display { color: var(--paper); }

.ds-container { max-width: var(--ds-container); margin-inline: auto; }
.ds-container--wide { max-width: var(--ds-container-wide); }
.ds-container--narrow { max-width: 720px; margin-inline: auto; }
.ds-measure { max-width: var(--ds-measure); }

.ds-stack > * + * { margin-top: var(--ds-space-md); }

.ds-grid { display: grid; gap: var(--ds-space-lg); }
.ds-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ds-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ds-grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1024px) { .ds-grid--3, .ds-grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 767px) { .ds-grid--2, .ds-grid--3, .ds-grid--4 { grid-template-columns: 1fr; } }

/* Editorial 2-col section header: label/h2 left, paragraph right (brand §7.3) */
.ds-section-head { display: grid; grid-template-columns: 1fr 1fr; gap: var(--ds-space-xl); align-items: end; }
@media (max-width: 767px) { .ds-section-head { grid-template-columns: 1fr; gap: var(--ds-space-md); } }

/* ============================================================ TYPOGRAPHY */
.ds-eyebrow {
	font-family: var(--font-mono); font-size: var(--ds-text-xs);
	font-weight: var(--ds-weight-medium); letter-spacing: var(--ds-tracking-eyebrow);
	text-transform: uppercase; color: var(--ink-3);
}
.ds-eyebrow--red { color: var(--red); }
.ds-display { font-size: var(--ds-text-display); font-weight: var(--ds-weight-head); letter-spacing: var(--ds-tracking-head); line-height: 1.02; color: var(--ink); text-wrap: balance; }
.ds-h2 { font-size: var(--ds-text-3xl); font-weight: var(--ds-weight-head); letter-spacing: var(--ds-tracking-head); line-height: var(--ds-leading-tight); color: var(--ink); text-wrap: balance; }
.ds-h3 { font-size: var(--ds-text-xl); font-weight: var(--ds-weight-semibold); letter-spacing: var(--ds-tracking-head); color: var(--ink); }
.ds-lead { font-size: var(--ds-text-lg); color: var(--ink-2); line-height: 1.45; max-width: var(--ds-measure); }
.ds-body { font-size: var(--ds-text-base); color: var(--ink); line-height: var(--ds-leading); max-width: var(--ds-measure); }
.ds-muted { color: var(--ink-2); }
.ds-mono { font-family: var(--font-mono); }
.ds-text-center { text-align: center; }

/* Numbered annotation label (01, 02, 03) — DM Mono, red accent (brand §7.4) */
.ds-num { font-family: var(--font-mono); font-size: var(--ds-text-sm); font-weight: var(--ds-weight-medium); color: var(--red); }

/* ============================================================ BUTTONS
 * Primary = ink (the standard dark button). CTA = red (order / high-emphasis).
 * Never use blue/green/gold for buttons (reserved for the product).
 */
.ds-btn {
	display: inline-flex; align-items: center; gap: var(--ds-space-2xs);
	padding: var(--ds-space-xs) var(--ds-space-md); border-radius: var(--ds-radius-full);
	font-family: var(--font-sans); font-weight: var(--ds-weight-medium); font-size: var(--ds-text-base);
	line-height: 1; text-decoration: none; cursor: pointer; border: 0;
	transition: background-color var(--ds-transition), color var(--ds-transition);
}
.ds-btn--primary { background-color: var(--ink); color: var(--paper); }
.ds-btn--primary:hover { background-color: #000; color: var(--paper); }
.ds-btn--cta { background-color: var(--red); color: #fff; }
.ds-btn--cta:hover { background-color: var(--red-deep); color: #fff; }
.ds-btn--ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-2); }
.ds-btn--ghost:hover { box-shadow: inset 0 0 0 1px var(--ink); }

/* ============================================================ SURFACES
 * Hairline borders, 14px radius, NO drop shadows (brand §7.3).
 */
.ds-card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--ds-radius); padding: var(--ds-space-lg); }
.ds-card__title { font-size: var(--ds-text-lg); font-weight: var(--ds-weight-semibold); letter-spacing: var(--ds-tracking-head); color: var(--ink); }
/* Monospace metadata strip along the bottom of product cards (brand §7.3) */
.ds-card__meta { margin-top: var(--ds-space-md); padding-top: var(--ds-space-sm); border-top: 1px solid var(--line); font-family: var(--font-mono); font-size: var(--ds-text-xs); color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.08em; }

.ds-pill { display: inline-flex; align-items: center; padding: var(--ds-space-3xs) var(--ds-space-xs); border-radius: var(--ds-radius-full); border: 1px solid var(--line); background: var(--paper); font-size: var(--ds-text-xs); font-weight: var(--ds-weight-medium); color: var(--ink-2); }

/* Medical-alert header — the ONE place red + alert styling is sanctioned */
.ds-alert { background: var(--red); color: #fff; padding: var(--ds-space-2xs) var(--ds-space-sm); border-radius: var(--ds-radius-sm); font-weight: var(--ds-weight-medium); }
.ds-alert--soft { background: var(--red-soft); color: var(--red-deep); }

/* ============================================================ POUCH STRIPE
 * The four logo colours, reserved for the signature pouch-stripe motif.
 */
.ds-stripe { display: flex; height: 4px; border-radius: 2px; overflow: hidden; }
.ds-stripe > span { flex: 1; }
.ds-stripe > .is-red { background: var(--red); }
.ds-stripe > .is-blue { background: var(--blue); }
.ds-stripe > .is-green { background: var(--green); }
.ds-stripe > .is-gold { background: var(--gold); }

/* ============================================================ CLIENT OVERRIDES
 * Allergy Buddy is already brand-mapped above. If a value needs tuning, change
 * the brand token (e.g. --red, --bg) here rather than the component rules.
 */

/* GenerateBlocks global classes. Same rules as generateblocks_style_css,
   which is stored in the database and uploads, not in the theme folder. */
.ab-btn,
.ab-btn-ghost,
.ab-btn-ink,
.ab-btn-light {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 9px;
	padding: 14px 22px;
	border: 1.5px solid transparent;
	border-radius: 999px;
	font-family: var(--ab-sans);
	font-size: 14.5px;
	font-weight: 500;
	line-height: 1;
	text-decoration: none;
}
.ab-btn { background-color: var(--ab-red); border-color: var(--ab-red); color: var(--ab-white); }
.ab-btn:hover { background-color: var(--ab-red-deep); border-color: var(--ab-red-deep); color: var(--ab-white); }
.ab-btn-ghost { background-color: transparent; border-color: var(--ab-line-2); color: var(--ab-ink); }
.ab-btn-ghost:hover { border-color: var(--ab-ink); color: var(--ab-ink); }
.ab-btn-ink { background-color: var(--ab-ink); border-color: var(--ab-ink); color: var(--ab-paper); }
.ab-btn-ink:hover { background-color: #000; border-color: #000; color: var(--ab-paper); }
.ab-btn-light { background-color: var(--ab-paper); border-color: var(--ab-paper); color: var(--ab-ink); }
.ab-btn-light:hover { background-color: var(--ab-white); color: var(--ab-ink); }
.ab-btn-sm { padding: 10px 16px; font-size: 13px; }
.ab-card {
	display: flex;
	flex-direction: column;
	gap: 16px;
	position: relative;
	padding: 26px 24px;
	background-color: var(--ab-paper);
	border: 1px solid var(--ab-line);
	border-radius: var(--ab-radius);
}
.ab-card:hover { border-color: var(--ab-line-2); }

/* Card action: price (and "ex GST" / "Quote on request") above a full-width button.
   Beats the GenerateBlocks footer rule (.gb-element-*) which lays them out in a row. */
.ab-card > div:has(> a:is(.ab-btn, .ab-btn-ink, .ab-btn-ghost, .ab-btn-light)) {
	flex-direction: column;
	align-items: stretch;
	justify-content: flex-start;
}
.ab-card > div:has(> a:is(.ab-btn, .ab-btn-ink, .ab-btn-ghost, .ab-btn-light)) > a {
	width: 100%;
	max-width: 100%;
	min-width: 0;
	box-sizing: border-box;
}

@media (max-width: 760px) {
	.ab-card { flex: 0 0 82%; scroll-snap-align: start; }

	/* Phone rail bleeds to the viewport (negative margin) and pads 18px, the same
	   inset as the homepage column. Mandatory snap ignores that padding and parks
	   the first card on the screen edge unless the snapport is inset to match.
	   Trailing padding on the rail keeps the last card fully in view. */
	:has(> .ab-card) {
		scroll-padding-inline: 18px;
	}
}

/* Hero proof points: one per line, full width of the copy column.
   Beats the GenerateBlocks row (.gb-element-ab0094). */
#ab-hero .gb-element-ab0094 {
	flex-direction: column;
	flex-wrap: nowrap;
	align-items: stretch;
	width: 100%;
}
#ab-hero .gb-element-ab0094 > * {
	width: 100%;
	max-width: 100%;
}
#ab-hero .gb-element-ab0094 > * > span:last-child {
	min-width: 0;
}

/* Product chooser — first section after the hero.
   Mockup .chooser is 18px / 8px, and its heading sits 32px above the cards
   (later sections keep the 48px head margin). */
.home #ab-hero + section > div > div:first-of-type {
	margin-bottom: 32px;
}
