/* ══════════════════════════════════════════════════════
   Xmas baubles: configurator [xmas_baubles] and fulfilment
   page [xmas_baubles_fulfilment].

   Theme hooks: set any --xb-* token on :root or body in the
   theme; the defaults below are neutral. See README.
   ══════════════════════════════════════════════════════ */

/* The lettering font (also loaded alone by xmas_baubles_render_bauble()).
   An @import, so pages cached with only this stylesheet's <link> get it too. */
@import url("xb-font.css");

.xb, .xbf {
	--_ink: var(--xb-ink, #1f2328);
	--_muted: var(--xb-muted, #5b6169);
	--_bg: var(--xb-bg, #ffffff);
	--_panel: var(--xb-panel, #f7f5f0);
	--_line: var(--xb-line, rgba(31, 35, 40, .14));
	--_accent: var(--xb-accent, #a3121f);
	--_accent-ink: var(--xb-accent-ink, #ffffff);
	--_accent-text: var(--xb-accent-text, #a3121f);
	--_error: var(--xb-error, #b42318);
	--_focus: var(--xb-focus, #1a5fb4);
	--_radius: var(--xb-radius, 14px);
	--_radius-sm: var(--xb-radius-sm, 8px);
	--_font: var(--xb-font-body, inherit);
	--_font-heading: var(--xb-font-heading, inherit);
	--_script: var(--xb-font-family, "XB Script", "Snell Roundhand", "Segoe Script", "Brush Script MT", "Apple Chancery", cursive);
	--_mono: var(--xb-font-mono, ui-monospace, "SF Mono", Menlo, Consolas, monospace);
	--_stage: var(--xb-stage, radial-gradient(120% 90% at 50% 0%, #fbf8f1 0%, #efe9dc 100%));

	font-family: var(--_font);
	color: var(--_ink);
	line-height: 1.55;
}
.xb *, .xb *::before, .xb *::after,
.xbf *, .xbf *::before, .xbf *::after { box-sizing: border-box; }
.xb [hidden], .xbf [hidden] { display: none !important; }

/* Headings: by class only, so heading_level (h1-h5) never changes their look. */
.xb-heading, .xb-subheading, .xbf-card__title {
	font-family: var(--xb-heading-font, var(--_font-heading));
	text-transform: var(--xb-heading-transform, none);
	line-height: 1.2; margin: 0 0 .75rem;
}
.xb-heading { font-size: clamp(1.35rem, 1.1rem + 1vw, 1.75rem); }
.xb-heading:focus { outline: none; }
.xb-subheading { font-size: 1.1rem; margin-top: 2rem; }

.xb-sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.xb-hint, .xb-small { color: var(--_muted); font-size: .875rem; margin: .35rem 0 0; }
.xb-small { margin-top: 1rem; }
.xb-error { color: var(--_error); font-size: .875rem; font-weight: 600; margin: .3rem 0 0; min-height: 0; }
.xb-error:empty { display: none; }
.xb-notice { background: var(--_panel); border-radius: var(--_radius); padding: 1.25rem 1.5rem; font-size: 1.05rem; }
.xb-loading { color: var(--_muted); }

/* Focus: always visible, never removed. */
.xb :focus-visible, .xbf :focus-visible { outline: 3px solid var(--_focus); outline-offset: 2px; }

/* ---------- buttons ---------- */
.xb-btn {
	display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
	min-height: 48px; padding: .7rem 1.4rem;
	border: 2px solid var(--_accent); border-radius: 999px;
	background: transparent; color: var(--_accent-text);
	font: inherit; font-family: var(--xb-button-font, inherit); font-size: var(--xb-button-size, inherit); font-weight: var(--xb-button-weight, 700); cursor: pointer;
	text-transform: var(--xb-button-transform, none);
	transition: background-color .15s, color .15s, transform .15s;
}
.xb-btn--primary { background: var(--_accent); color: var(--_accent-ink); }
.xb-btn--primary:hover { filter: brightness(1.08); }
.xb-btn--ghost:hover { background: color-mix(in srgb, var(--_accent) 8%, transparent); }
.xb-btn:active { transform: translateY(1px); }
.xb-btn:disabled { opacity: .45; cursor: not-allowed; }
.xb-btn[aria-busy="true"] { cursor: progress; opacity: .75; }
.xb-actions { display: flex; flex-wrap: wrap; gap: .75rem; justify-content: flex-end; margin-top: 1.75rem; }

/* ---------- steps ---------- */
.xb-steps { display: flex; gap: .5rem; list-style: none; margin: 0 0 1.5rem; padding: 0; counter-reset: xb; font-size: .9rem; font-family: var(--xb-steps-font, inherit); text-transform: var(--xb-steps-transform, none); }
.xb-steps li { flex: 1; counter-increment: xb; padding-top: .6rem; border-top: 4px solid var(--_line); color: var(--_muted); }
.xb-steps li::before { content: counter(xb) ". "; }
.xb-steps li[aria-current], .xb-steps li.is-done { border-color: var(--_accent); color: var(--_ink); font-weight: 600; }

/* ---------- layout (mobile first) ---------- */
.xb-layout { display: grid; gap: 1.5rem; }
@media (min-width: 960px) {
	.xb-layout { grid-template-columns: minmax(0, 1fr) 300px; align-items: start; }
	.xb-summary { position: sticky; top: 1.5rem; }
}

/* ---------- designer ---------- */
.xb-designer { display: grid; gap: 1.25rem; }
@media (min-width: 640px) { .xb-designer { grid-template-columns: minmax(220px, 1fr) minmax(0, 1.1fr); align-items: start; } }

.xb-stage { margin: 0; background: var(--_stage); border-radius: var(--_radius); padding: 1rem 1rem .5rem; display: flex; justify-content: center; }
.xb-stage__canvas { width: min(100%, 340px); }

.xb-bauble { display: block; width: 100%; height: auto; overflow: visible; }
.xb-ball { fill: var(--xb-ball); transition: fill .35s ease; }
.xb-fill { fill: var(--xb-deco); transition: fill .35s ease; }
.xb-stroke { fill: none; stroke: var(--xb-deco); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; transition: stroke .35s ease; }
.xb-text { fill: var(--xb-deco); font-family: var(--_script); font-weight: 700; letter-spacing: .01em; transition: fill .35s ease; }
.xb-swing { transform-origin: 100px 6px; }
.xb-bauble--big .xb-swing { animation: xb-swing 6s ease-in-out infinite; }
@keyframes xb-swing { 0%, 100% { transform: rotate(-1.6deg); } 50% { transform: rotate(1.6deg); } }

.xb-editing { font-weight: 700; margin: 0 0 .5rem; }
.xb-fieldset { border: 0; margin: 0 0 1.1rem; padding: 0; min-width: 0; }
.xb-fieldset legend { font-weight: 600; margin-bottom: .5rem; padding: 0; }

.xb-swatches, .xb-symbols { display: grid; gap: .5rem; }
/* Rows of three; a shorter last row is centred (8 symbols = 3 + 3 + 2), so labels such as
   "Campanellino" never have to break. Tiles never narrower than 5.75rem. */
.xb-symbols { display: flex; flex-wrap: wrap; justify-content: center; }
.xb-symbols > .xb-symbol { flex: 0 0 calc((100% - .5rem) / 2); min-width: 5.75rem; min-height: 5.4rem; }
/* Five or more symbols: rows of three. Up to four: two per row. */
.xb-symbols:has(> .xb-symbol:nth-child(5)) > .xb-symbol { flex-basis: calc((100% - 1rem) / 3); }
.xb-swatch, .xb-symbol {
	position: relative; display: flex; align-items: center; gap: .7rem;
	min-height: 52px; padding: .5rem .8rem;
	border: 2px solid var(--_line); border-radius: var(--_radius-sm);
	background: var(--_bg); cursor: pointer;
	transition: border-color .15s, box-shadow .15s;
}
.xb-swatch input, .xb-symbol input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.xb-swatch:has(input:checked), .xb-symbol:has(input:checked) { border-color: var(--_accent); box-shadow: 0 0 0 1px var(--_accent); }
.xb-swatch:has(input:focus-visible), .xb-symbol:has(input:focus-visible) { outline: 3px solid var(--_focus); outline-offset: 2px; }
.xb-swatch:has(input:disabled) { opacity: .5; cursor: not-allowed; }
.xb-swatch__dot {
	flex: none; width: 34px; height: 34px; border-radius: 50%;
	background: radial-gradient(circle at 35% 30%, rgba(255,255,255,.7), transparent 45%), var(--xb-ball);
	box-shadow: inset 0 0 0 4px var(--xb-ball), inset 0 0 0 6px var(--xb-deco), 0 0 0 1px var(--xb-bauble-outline, #767676);
}
.xb-swatch__text { display: flex; flex-direction: column; line-height: 1.25; }
.xb-swatch__left { font-size: .8rem; color: var(--_muted); }
/* Symbol tiles: icon centred above the label, equal heights. */
.xb-symbol { flex-direction: column; justify-content: center; gap: .35rem; min-height: 5.25rem; padding: .65rem .4rem; text-align: center; line-height: 1.2; font-size: .9rem; }
.xb-symbol > span { overflow-wrap: anywhere; hyphens: auto; }
.xb-symbol__icon { flex: none; width: 34px; height: 30px; --xb-deco: var(--_ink); --xb-ball: var(--_bg); }

.xb-field { margin-bottom: .9rem; }
.xb-field > label { display: block; font-weight: 600; margin-bottom: .35rem; }
.xb input[type="text"], .xb input[type="email"], .xb input[type="tel"], .xb textarea,
.xbf input[type="text"], .xbf input[type="email"] {
	width: 100%; min-height: 48px; padding: .65rem .85rem;
	border: 2px solid var(--_line); border-radius: var(--_radius-sm);
	background: var(--_bg); color: var(--_ink); font: inherit; font-size: 1rem;
}
.xb [aria-invalid="true"], .xbf [aria-invalid="true"] { border-color: var(--_error); }
.xb-textrow { display: flex; gap: .5rem; }
.xb-textrow input { font-size: 1.15rem !important; }
.xb-heart { flex: none; width: 48px; padding: 0; }

/* ---------- list of baubles ---------- */
.xb-list { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: .5rem; }
.xb-item { display: flex; align-items: stretch; gap: .4rem; }
.xb-item__pick {
	flex: 1; display: flex; align-items: center; gap: .8rem; min-height: 64px;
	padding: .35rem .8rem .35rem .35rem; text-align: left;
	border: 2px solid var(--_line); border-radius: var(--_radius-sm);
	background: var(--_bg); color: inherit; font: inherit; cursor: pointer;
}
.xb-item.is-current .xb-item__pick { border-color: var(--_accent); background: var(--_panel); }
.xb-item__pick .xb-bauble { width: 48px; flex: none; }
.xb-item__label { display: flex; flex-direction: column; line-height: 1.3; font-size: .9rem; }
.xb-item__remove {
	flex: none; width: 48px; border: 2px solid var(--_line); border-radius: var(--_radius-sm);
	background: var(--_bg); color: var(--_muted); font-size: 1.4rem; cursor: pointer;
}
.xb-item__remove:hover { color: var(--_error); border-color: var(--_error); }

/* ---------- summary ---------- */
.xb-summary { background: var(--_panel); border-radius: var(--_radius); padding: 1.25rem 1.4rem; }
.xb-heading.xb-summary__title { font-size: var(--xb-summary-heading-size, 1.1rem); }
.xb-summary dl { display: grid; gap: .35rem; margin: 0; }
.xb-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: .1rem 1rem; }
.xb-summary dt, .xb-summary dd { margin: 0; }
.xb-summary dd { margin-left: auto; text-align: right; font-variant-numeric: tabular-nums; }
.xb-row.xb-total { border-top: 1px solid var(--_line); padding-top: .5rem; font-weight: 700; font-size: 1.1rem; }
.xb-raised { font-weight: 600; color: var(--_accent-text); }
.xb-raised:empty { display: none; }

/* ---------- step 2 form ---------- */
.xb-form { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 0 .9rem; }
.xb-form > * { grid-column: 1 / -1; }
@media (min-width: 560px) {
	.xb-form > .xb-half { grid-column: span 3; }
	.xb-form > .xb-wide { grid-column: span 4; }
	.xb-form > .xb-narrow { grid-column: span 2; }
}
.xb-check { display: grid; grid-template-columns: auto 1fr; gap: .2rem .6rem; align-items: start; }
.xb-check input { width: 24px; height: 24px; margin: .1rem 0 0; accent-color: var(--_accent); }
.xb-check label { font-weight: 400; }
.xb-check .xb-error { grid-column: 2; }
.xb-hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- step 3 ---------- */
.xb-frame { margin-top: 1rem; }
.xb-iframe { display: block; width: 100%; min-height: 560px; border: 0; border-radius: var(--_radius); background: var(--_bg); }
.xb-confirm, .xb-thanks { background: var(--_panel); border-radius: var(--_radius); padding: 2rem 1.5rem; text-align: center; }
.xb-spinner { display: inline-block; width: 40px; height: 40px; margin-bottom: 1rem; border: 4px solid var(--_line); border-top-color: var(--_accent); border-radius: 50%; animation: xb-spin 1s linear infinite; }
.xb-confirm.is-slow .xb-spinner { display: none; }
@keyframes xb-spin { to { transform: rotate(360deg); } }
.xb-recap { list-style: none; padding: 0; margin: 1.5rem auto 0; max-width: 460px; display: grid; gap: .5rem; text-align: left; }
.xb-recap li { display: flex; align-items: center; gap: .8rem; background: var(--_bg); border-radius: var(--_radius-sm); padding: .35rem .8rem .35rem .35rem; }
.xb-recap .xb-bauble { width: 48px; flex: none; }

/* ---------- transparency ---------- */
.xb-info { margin-top: 2.5rem; padding-top: 1.5rem; border-top: 1px solid var(--_line); font-size: .92rem; }
.xb-heading.xb-info__title { font-size: 1.1rem; }
.xb-info--compact { font-size: .9rem; color: var(--_muted); }
.xb-info dt { font-weight: 700; margin-top: .9rem; }
.xb-info dd { margin: .2rem 0 0; color: var(--_muted); }

/* ---------- fulfilment page ---------- */
.xbf { max-width: 760px; margin: 0 auto; }
.xbf-login { background: var(--_panel); border-radius: var(--_radius); padding: 1.5rem; }
.xbf-login input[type="text"] { font-family: var(--_mono); font-size: 1.6rem !important; letter-spacing: .3em; text-align: center; }
.xbf-bar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.xbf-tabs { display: flex; gap: .4rem; }
.xbf-tabs .xb-btn[aria-pressed="true"] { background: var(--_accent); color: var(--_accent-ink); }
.xbf-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; }
.xbf-card { border: 2px solid var(--_line); border-radius: var(--_radius); padding: 1.1rem; background: var(--_bg); }
.xbf-card.is-shipped { background: var(--_panel); }
.xbf-card__head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .25rem 1rem; margin-bottom: .75rem; }
.xbf-card__title { margin: 0; font-size: 1.15rem; }
.xbf-due { font-weight: 700; color: var(--_accent-text); }
.xbf-baubles { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: .6rem; }
.xbf-baubles li { border-left: 4px solid var(--_accent); padding: .3rem 0 .3rem .75rem; }
.xbf-text { display: inline-block; margin-top: .2rem; padding: .25rem .6rem; background: var(--_panel); border-radius: 6px; font-family: var(--_mono); font-size: 1.5rem; line-height: 1.3; white-space: pre; overflow-x: auto; max-width: 100%; }
.xbf-addr { white-space: pre-line; background: var(--_panel); border-radius: var(--_radius-sm); padding: .75rem .9rem; margin: 0 0 .5rem; }
.xbf-ship { display: grid; gap: .6rem; margin-top: 1rem; }
@media (min-width: 560px) { .xbf-ship { grid-template-columns: 1fr 1fr auto; align-items: end; } }
.xbf-ok { color: #1a7f37; font-weight: 700; }

@media (prefers-reduced-motion: reduce) {
	.xb *, .xbf * { animation: none !important; transition: none !important; }
}
