/**
 * TB POS — Design Tokens
 *
 * Bahamian hospitality: deep Atlantic ink, lagoon teal, champagne gold,
 * soft coral. Editorial display type + calm UI sans. Consume variables only.
 *
 * Scoped under #tb-pos-app so WordPress admin chrome is never overridden.
 */

#tb-pos-app,
.tb-pos-root {
	/* Brand — Tickets Bahamas hospitality */
	--tb-coral: #e8a090;
	--tb-coral-deep: #c97b6c;
	--tb-teal: #1a6b74;
	--tb-teal-deep: #0f4f56;
	--tb-teal-wash: #e8f2f3;
	--tb-text-on-teal: #ffffff;
	--tb-shell-gold: #c4a574;
	/* Deepened from #9a7d52, which carried white text at 3.87:1. */
	--tb-shell-gold-deep: #7d6540;
	--tb-shell-cream: #e8ddd6;
	--tb-deep-rose: #8a554f;
	--tb-ink: #0b1218;
	--tb-ink-soft: #152028;

	--tb-black: #0b1218;
	--tb-white: #ffffff;

	/* Surfaces — warm stone atmosphere, not flat grey SaaS */
	--tb-bg: #f3efe8;
	--tb-bg-glow: radial-gradient(120% 80% at 100% 0%, rgba(26, 107, 116, 0.07), transparent 55%),
		radial-gradient(90% 60% at 0% 100%, rgba(196, 165, 116, 0.08), transparent 50%),
		linear-gradient(180deg, #f6f2eb 0%, #efe9e0 100%);
	--tb-surface: rgba(255, 252, 248, 0.92);
	--tb-surface-solid: #fffcf8;
	--tb-surface-alt: #ebe4da;
	/* The header was a hardcoded rgba(255,252,248,0.78): a near-white bar that
	   stayed near-white under Night while the text on it went near-white too.
	   Same bug as the toast, in the strip above every screen. */
	--tb-header-bg: rgba(255, 252, 248, 0.78);
	/* A scrim is a shade over the page, so it is dark in every theme by
	   intent rather than by accident. Named so that is a decision. */
	--tb-scrim: rgba(0, 0, 0, 0.45);
	--tb-sidebar: linear-gradient(185deg, #0e1a22 0%, #0b1218 48%, #0a161c 100%);
	--tb-sidebar-solid: #0b1218;
	--tb-sidebar-hover: rgba(255, 255, 255, 0.06);
	/* Sidebar chrome. Fixed across themes on purpose — the sidebar is dark in
	   all of them — but tokenised so that is visible and editable in one place. */
	--tb-sidebar-tint: rgba(255, 252, 248, 0.04);
	--tb-sidebar-active-bg: rgba(26, 107, 116, 0.22);
	--tb-sidebar-text: #c8c2ba;
	--tb-sidebar-text-muted: #938d85;

	/* Text */
	--tb-text-primary: #12181e;
	--tb-text-secondary: #5c5852;
	--tb-text-inverse: #fffcf8;
	--tb-text-on-coral: #12181e;
	--tb-text-on-gold: #12181e;
	--tb-text-on-gold-deep: #ffffff;

	/* --------------------------------------------------------------------
	 * Inverse surface — a panel that has to stand apart from the page in
	 * EVERY theme: toasts, tooltips.
	 *
	 * This exists because the obvious shortcut is wrong. `background:
	 * var(--tb-text-primary)` reads as "the dark colour" and works in two of
	 * three themes — then Night flips text-primary to near-white and the toast
	 * becomes white text on a white slab. A background needs a background
	 * token whose value is chosen per theme, not a text token borrowed for its
	 * current lightness.
	 */
	--tb-inverse-surface: #12181e;
	--tb-text-on-inverse: #ffffff;

	/* The sidebar is dark in every theme, so its labels do NOT follow
	 * --tb-text-inverse, which flips with the page. */
	--tb-sidebar-text-active: #ffffff;

	/* Input surfaces, so a field is never a hardcoded near-white slab that a
	 * dark theme then writes pale text onto. */
	--tb-field-bg: rgba(255, 252, 248, 0.7);
	--tb-field-bg-solid: #fffcf8;

	/* Borders — quiet hairlines */
	--tb-border: rgba(18, 24, 30, 0.08);
	/* "Strong" has to mean visible. At 0.14 this measured 1.34:1 against a
	   card — below the 3:1 WCAG 1.4.11 asks of a control's boundary, which is
	   why a secondary button read as floating text rather than a button. The
	   hairline above is decorative and stays quiet. */
	--tb-border-strong: rgba(18, 24, 30, 0.48);
	--tb-border-gold: rgba(196, 165, 116, 0.45);

	/* --------------------------------------------------------------------
	 * Operational colours come in THREE parts, and using the wrong one is
	 * the single most common contrast bug in this codebase:
	 *
	 *   --tb-{status}          the accent: solid fills, dots, icons, borders
	 *   --tb-{status}-wash     the tint behind a badge or alert
	 *   --tb-{status}-text     text ON that tint  — never the accent itself
	 *   --tb-text-on-{status}  text ON the solid accent fill
	 *
	 * An accent is tuned to carry weight as a *fill*. The same value used as
	 * *text on its own tint* is two shades too light: amber on cream measured
	 * 2.88:1. They are different jobs and now different tokens.
	 */
	--tb-success: #1f7a5c;
	--tb-success-wash: #e8f4ef;
	--tb-success-text: #1f7a5c;
	--tb-text-on-success: #ffffff;

	--tb-warning: #b8862e;
	--tb-warning-wash: #f8f1e3;
	--tb-warning-text: #8e6723;
	--tb-text-on-warning: #12181e;

	--tb-danger: #b8433f;
	--tb-danger-wash: #f8eceb;
	--tb-danger-text: #b8433f;
	--tb-text-on-danger: #ffffff;

	--tb-info: #1a6b74;
	--tb-info-wash: #e8f2f3;
	--tb-info-text: #1a6b74;
	--tb-text-on-info: #ffffff;

	--tb-muted: #7a756e;
	--tb-muted-wash: #ebe6df;
	--tb-muted-text: #6b6761;

	/* Status accents */
	--tb-status-requested: #1a6b74;
	--tb-status-picking: #b8862e;
	--tb-status-ready: #1f7a5c;
	--tb-status-urgent: #b8433f;
	--tb-status-fulfilled: #4d8a72;

	/* Typography — display serif + refined UI sans (never Inter/system default stack) */
	--tb-font-display: "Cormorant Garamond", "Times New Roman", Georgia, serif;
	--tb-font: "Outfit", "Avenir Next", "Segoe UI", sans-serif;
	--tb-font-mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;

	/* Every type size is expressed through --tb-font-scale so the whole UI can
	   be enlarged *proportionally*. Enlarging text through the browser's own
	   minimum-font-size floor cannot do this: a floor of 24px turns 15px, 14px
	   and 12px all into 24px, so name, price and stock become indistinguishable
	   and the design's hierarchy disappears at exactly the moment someone needs
	   it most. Scaling keeps the relationships intact. */
	--tb-font-scale: 1;

	--tb-text-page: calc(clamp(1.75rem, 2vw, 2.25rem) * var(--tb-font-scale));
	--tb-text-section: calc(1.25rem * var(--tb-font-scale));
	--tb-text-metric: calc(clamp(1.75rem, 2.2vw, 2.125rem) * var(--tb-font-scale));
	--tb-text-body: calc(0.9375rem * var(--tb-font-scale));
	--tb-text-label: calc(0.75rem * var(--tb-font-scale));
	--tb-text-badge: calc(0.6875rem * var(--tb-font-scale));
	--tb-text-control: calc(0.9375rem * var(--tb-font-scale));

	/* Fills the gaps the screens were reaching past the scale for. Every one
	   carries --tb-font-scale, so a hardcoded px anywhere in a screen is now a
	   bug: it is a piece of UI that will not grow when someone turns the text
	   up, and it will end up the smallest thing on a screen they enlarged
	   precisely because they could not read it. */
	--tb-text-2xs: calc(0.625rem * var(--tb-font-scale));   /* 10px */
	--tb-text-xs: calc(0.8125rem * var(--tb-font-scale));   /* 13px */
	--tb-text-sm: calc(0.875rem * var(--tb-font-scale));    /* 14px */
	--tb-text-md: calc(1rem * var(--tb-font-scale));        /* 16px */
	--tb-text-lg: calc(1.125rem * var(--tb-font-scale));    /* 18px */
	--tb-text-xl: calc(1.25rem * var(--tb-font-scale));     /* 20px */
	--tb-text-2xl: calc(1.375rem * var(--tb-font-scale));   /* 22px */
	--tb-text-3xl: calc(1.5rem * var(--tb-font-scale));     /* 24px */
	--tb-text-4xl: calc(1.75rem * var(--tb-font-scale));    /* 28px */
	--tb-text-5xl: calc(2.5rem * var(--tb-font-scale));     /* 40px */

	--tb-leading-tight: 1.15;
	--tb-leading-body: 1.55;

	/* Spacing */
	--tb-space-1: 4px;
	--tb-space-2: 8px;
	--tb-space-3: 12px;
	--tb-space-4: 16px;
	--tb-space-5: 20px;
	--tb-space-6: 24px;
	--tb-space-8: 32px;
	--tb-space-10: 40px;
	--tb-space-12: 48px;

	/* Radius — soft, architectural (not pill-heavy) */
	--tb-radius-sm: 4px;
	--tb-radius-md: 8px;
	--tb-radius-lg: 12px;
	--tb-radius-xl: 16px;

	/* Elevation — single soft plane, no stacked chrome */
	--tb-shadow-sm: 0 1px 0 rgba(18, 24, 30, 0.04);
	--tb-shadow-md: 0 12px 40px rgba(11, 18, 24, 0.06);
	/* Focus ring.
	 *
	 * Was a single 28%-alpha teal glow, which measured 1.52:1 against a card
	 * — present in the CSS, invisible on screen. A till is worked by people
	 * tabbing between fields with one hand; they have to be able to see where
	 * they are.
	 *
	 * Two solid rings: a surface-coloured inner one to separate the ring from
	 * whatever it sits on, then the accent. That way it stays visible on a
	 * white card, a teal button and a dark sidebar alike, instead of being
	 * tuned for one of them. */
	--tb-focus-ring: #0f4f56;
	--tb-shadow-focus: 0 0 0 2px var(--tb-surface-solid), 0 0 0 4px var(--tb-focus-ring);
	/* The sidebar is dark in every theme, so the ring that works on a card is
	   invisible there. Same system, lifted for a dark ground. */
	--tb-focus-ring-dark: #5fd0e3;
	--tb-shadow-focus-dark: 0 0 0 2px var(--tb-sidebar-solid), 0 0 0 4px var(--tb-focus-ring-dark);

	/* Layout */
	--tb-sidebar-width: 260px;
	--tb-sidebar-collapsed: 76px;
	--tb-header-height: 72px;
	/* Touch targets grow with the type they contain, but never shrink below the
	   44/48px accessibility floor however small the scale. */
	--tb-touch-min: max(44px, calc(2.75rem * var(--tb-font-scale)));
	--tb-touch-pref: max(48px, calc(3rem * var(--tb-font-scale)));

	/* Motion */
	--tb-duration: 220ms;
	--tb-duration-slow: 420ms;
	--tb-ease: cubic-bezier(0.22, 1, 0.36, 1);

	/* Kitchen-display surface — the board is dark in every theme, because a
	   kitchen screen is read across a room. Night reuses these values for the
	   whole console; Service and Resort keep them scoped to the board. */
	--tb-kds-bg: #0a0a0a;
	--tb-kds-surface: #161616;
	--tb-kds-border: rgba(255, 255, 255, 0.12);
	--tb-kds-rule: rgba(255, 255, 255, 0.1);
	--tb-kds-text: #ffffff;
	--tb-kds-text-muted: rgba(255, 255, 255, 0.65);
	--tb-kds-text-dim: rgba(255, 255, 255, 0.55);
	--tb-kds-chip: rgba(255, 255, 255, 0.1);
	--tb-kds-chip-hover: rgba(255, 255, 255, 0.12);
	--tb-kds-chip-border: rgba(255, 255, 255, 0.22);
	/* Narrowest a kitchen ticket may be before the grid drops a column.
	   Raised on large screens further down, where a wider card reads better
	   from across a kitchen. */
	--tb-kds-card-min: 260px;
	/* Shortest a ticket may be. This was a flat 260px, which — with 20px
	   padding either side — made even a two-line order 302px tall. Two rows
	   then needed 624px on a board 619px high, so a 1280×800 screen fitted a
	   single row and everything else paged away. Raised again on large
	   screens further down, where a ticket is read from across a kitchen. */
	--tb-kds-card-h: 200px;

	/* Z-index */
	--tb-z-sidebar: 40;
	--tb-z-header: 30;
	--tb-z-banner: 50;
	--tb-z-modal: 100;
	--tb-z-toast: 110;
	--tb-z-tooltip: 120;
}

/* ------------------------------------------------------------------ Text size
 *
 * A display preference, set per device and remembered, mirroring how themes
 * work. Four steps: the ratios between sizes are preserved at every one, so a
 * product name stays visibly larger than its stock count no matter how big the
 * UI gets.
 *
 * This exists so nobody has to reach for the browser's minimum-font-size
 * setting, which flattens every size to the same floor and then overflows
 * containers that were laid out for the original sizes.
 */

#tb-pos-app[data-tb-text="lg"],
.tb-pos-root[data-tb-text="lg"] {
	--tb-font-scale: 1.15;
}

#tb-pos-app[data-tb-text="xl"],
.tb-pos-root[data-tb-text="xl"] {
	--tb-font-scale: 1.35;
}

#tb-pos-app[data-tb-text="xxl"],
.tb-pos-root[data-tb-text="xxl"] {
	--tb-font-scale: 1.6;
}
