/* ==========================================================================
   Cunto Dalbo - design tokens + shared UI primitives (single source of truth)
   Loaded first on every page (customer site, QR pages, staff/platform, print).
   Values come from cunto-dalbo-brand-kit/tokens/brand.css + brand-guide.md.
   Never hard-code brand colours elsewhere: use the variables below.
   ========================================================================== */

/* ---- Poppins, self-hosted (SIL OFL 1.1, assets/fonts/poppins/OFL.txt) ---- */
@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('../fonts/poppins/poppins-latin-400-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('../fonts/poppins/poppins-latin-500-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('../fonts/poppins/poppins-latin-600-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 700; font-display: swap;
  src: url('../fonts/poppins/poppins-latin-700-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('../fonts/poppins/poppins-latin-ext-400-normal.woff2') format('woff2');
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('../fonts/poppins/poppins-latin-ext-500-normal.woff2') format('woff2');
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('../fonts/poppins/poppins-latin-ext-600-normal.woff2') format('woff2');
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 700; font-display: swap;
  src: url('../fonts/poppins/poppins-latin-ext-700-normal.woff2') format('woff2');
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

:root {
  /* ---- Brand palette ---- */
  --cd-gold: #FFB02E;
  --cd-amber: #FFA52E;
  --cd-orange: #FF6A1A;
  --cd-tomato: #E63B1F;
  --cd-espresso: #3A0F05;
  --cd-espresso-deep: #2A0B04;
  --cd-roast: #4A1608;
  --cd-night: #220804;
  --cd-cream: #FFF4E0;
  --cd-cream-light: #FFFBF2;
  --cd-cream-deep: #FFE3B8;
  --cd-sand: #F2D9B8;
  --cd-clay: #7A3A20;
  --cd-tan: #CDAE90;
  --cd-white: #FFFFFF;

  /* ---- Gradients ---- */
  --cd-gradient: linear-gradient(135deg, #FFB02E 0%, #EC4826 100%);   /* ends on a slightly lighter tomato so dark text stays AA (4.8:1) */
  --cd-gradient-soft: linear-gradient(135deg, #FFB02E 0%, #FF6A1A 55%, #E63B1F 100%);
  --cd-gradient-dark: linear-gradient(180deg, #4A1608 0%, #220804 100%);
  --cd-gradient-light: radial-gradient(circle at 50% 0%, #FFFBF2 0%, #FFF4E0 45%, #FFE3B8 100%);

  /* ---- Order status (brand guide) ---- */
  --cd-danger-solid: #C42E14;   /* tomato darkened: white text passes AA (5.6:1) at any size */
  --cd-danger-solid-hover: #A3260F;
  --cd-status-new: #FFB02E;
  --cd-status-accepted: #FF6A1A;
  --cd-status-preparing: #E63B1F;
  --cd-status-on-the-way: #2E8BFF;
  --cd-status-delivered: #2FA84F;
  --cd-status-cancelled: #8A6F63;
  /* Text-safe versions for small status text on light tints (WCAG AA) */
  --cd-status-new-ink: #7A4A00;
  --cd-status-accepted-ink: #9A3A00;
  --cd-status-preparing-ink: #A3260F;
  --cd-status-on-the-way-ink: #0B4FA8;
  --cd-status-delivered-ink: #1B6B30;
  --cd-status-cancelled-ink: #5E4A41;

  /* ---- Shape / depth / motion ---- */
  --cd-radius-card: 28px;
  --cd-radius-tile: 24px;
  --cd-radius-input: 16px;
  --cd-radius-sm: 12px;
  --cd-radius-pill: 999px;
  --cd-shadow-card: 0 10px 30px rgba(58, 15, 5, 0.10);
  --cd-shadow-soft: 0 4px 14px rgba(58, 15, 5, 0.08);
  --cd-shadow-lift: 0 18px 40px rgba(58, 15, 5, 0.16);
  --cd-shadow-glow: 0 8px 24px rgba(230, 59, 31, 0.32);
  --cd-ease: cubic-bezier(.2, .7, .2, 1);
  --cd-fast: 160ms;
  --cd-med: 240ms;

  /* ---- Spacing (8px grid) ---- */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px; --sp-7: 48px; --sp-8: 64px;

  /* ---- Type ---- */
  --font-ui: 'Poppins', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --fs-xs: 12px; --fs-sm: 13px; --fs-md: 15px; --fs-lg: 18px; --fs-xl: 22px; --fs-2xl: 28px; --fs-3xl: clamp(30px, 6vw, 48px);

  /* ---- Semantic (LIGHT theme, default) ---- */
  --bg: var(--cd-cream);
  --bg-page: var(--cd-gradient-light);
  --surface: var(--cd-white);
  --surface-2: var(--cd-cream-light);
  --surface-sunken: #FCEBD0;
  --text: var(--cd-espresso);
  --text-muted: var(--cd-clay);
  --text-soft: #9A6A55;
  --border: rgba(58, 15, 5, 0.12);
  --border-strong: rgba(58, 15, 5, 0.22);
  --primary: var(--cd-orange);
  --on-primary: var(--cd-espresso-deep);
  --link: #B5400B;              /* orange darkened for AA text on cream/white */
  --focus: var(--cd-espresso);
  --skeleton: linear-gradient(90deg, #F6E3C6 0%, #FFF4E0 50%, #F6E3C6 100%);
  --danger: var(--cd-tomato);
  --danger-ink: #A3260F;
  --success-ink: #1B6B30;
  --header-bg: rgba(255, 251, 242, 0.88);
  color-scheme: light;
}

/* ---- DARK theme: espresso night gradient + glass cards with orange border ---- */
html[data-theme='dark'] {
  --bg: var(--cd-night);
  --bg-page: radial-gradient(circle at 85% -10%, rgba(255, 106, 26, 0.20), transparent 45%),
             radial-gradient(circle at -10% 110%, rgba(230, 59, 31, 0.18), transparent 50%),
             var(--cd-gradient-dark);
  --surface: rgba(255, 255, 255, 0.07);
  --surface-2: rgba(255, 255, 255, 0.04);
  --surface-sunken: rgba(0, 0, 0, 0.22);
  --text: #FFFFFF;
  --text-muted: var(--cd-sand);
  --text-soft: var(--cd-tan);
  --border: rgba(255, 154, 31, 0.45);
  --border-strong: rgba(255, 154, 31, 0.7);
  --link: var(--cd-amber);
  --focus: var(--cd-gold);
  --skeleton: linear-gradient(90deg, rgba(255,255,255,.05) 0%, rgba(255,255,255,.12) 50%, rgba(255,255,255,.05) 100%);
  --cd-shadow-card: 0 12px 30px rgba(0, 0, 0, 0.35);
  --cd-shadow-soft: 0 6px 16px rgba(0, 0, 0, 0.28);
  --cd-shadow-lift: 0 20px 44px rgba(0, 0, 0, 0.45);
  --danger-ink: #FF8A73;
  --success-ink: #7EE29A;
  --header-bg: rgba(34, 8, 4, 0.82);
  --cd-status-new-ink: #FFD38A;
  --cd-status-accepted-ink: #FFB07A;
  --cd-status-preparing-ink: #FF9C86;
  --cd-status-on-the-way-ink: #9CC8FF;
  --cd-status-delivered-ink: #8BE3A3;
  --cd-status-cancelled-ink: #E1CFC6;
  color-scheme: dark;
}

/* ==========================================================================
   Base
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-ui);
  font-weight: 500;
  color: var(--text);
  background: var(--bg);
  background-image: var(--bg-page);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; color: var(--text); }
a { color: var(--link); }
::selection { background: rgba(255, 106, 26, 0.28); color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 6px; }
input, select, textarea, button { font-family: inherit; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--cd-orange); width: 18px; height: 18px; }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: rgba(122, 58, 32, 0.45) transparent; }
html[data-theme='dark'] * { scrollbar-color: rgba(255, 154, 31, 0.5) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(122, 58, 32, 0.4); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
html[data-theme='dark'] ::-webkit-scrollbar-thumb { background-color: rgba(255, 154, 31, 0.45); }
::-webkit-scrollbar-track { background: transparent; }

/* Inline SVG icons from assets/brand/icons.svg */
.icon { width: 1.25em; height: 1.25em; fill: currentColor; flex: none; vertical-align: -0.25em; display: inline-block; }
.icon-sm { width: 1em; height: 1em; }
.icon-lg { width: 1.6em; height: 1.6em; }

.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ==========================================================================
   Primitives (prefixed .cd- so they never clash with page classes)
   ========================================================================== */

/* Buttons: primary = gradient pill + dark bold text (never small white on orange) */
.cd-btn {
  --btn-pad: 12px 22px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: var(--btn-pad);
  border-radius: var(--cd-radius-pill); border: 2px solid transparent;
  font: 700 var(--fs-md)/1.1 var(--font-ui); letter-spacing: .01em;
  text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: transform var(--cd-fast) var(--cd-ease), box-shadow var(--cd-fast) var(--cd-ease),
              filter var(--cd-fast) var(--cd-ease), background-color var(--cd-fast), color var(--cd-fast);
}
.cd-btn:active { transform: scale(0.97); }
.cd-btn[disabled], .cd-btn.is-disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; filter: grayscale(.2); }
.cd-btn-primary { background: var(--cd-gradient); color: var(--on-primary); box-shadow: var(--cd-shadow-glow); }
.cd-btn-primary:hover { filter: brightness(1.05) saturate(1.05); box-shadow: 0 10px 28px rgba(230, 59, 31, .38); }
.cd-btn-secondary { background: transparent; color: var(--link); border-color: var(--cd-orange); }
.cd-btn-secondary:hover { background: rgba(255, 106, 26, .1); }
.cd-btn-ghost { background: transparent; color: var(--text); }
.cd-btn-ghost:hover { background: rgba(255, 106, 26, .1); }
.cd-btn-dark { background: var(--cd-espresso); color: var(--cd-cream); }
.cd-btn-dark:hover { background: var(--cd-espresso-deep); }
.cd-btn-danger { background: var(--cd-danger-solid); color: #fff; }
.cd-btn-danger:hover { filter: brightness(1.06); }
.cd-btn-sm { --btn-pad: 8px 16px; min-height: 36px; font-size: var(--fs-sm); }
.cd-btn-lg { --btn-pad: 16px 30px; min-height: 54px; font-size: var(--fs-lg); }
.cd-btn-block { width: 100%; }
.cd-btn-icon { width: 44px; height: 44px; padding: 0; }

/* Round gradient "+" (menu rows) */
.cd-add {
  width: 40px; height: 40px; border-radius: 50%; border: 0; cursor: pointer;
  display: grid; place-items: center; background: var(--cd-gradient); color: var(--on-primary);
  box-shadow: var(--cd-shadow-glow); transition: transform var(--cd-fast) var(--cd-ease);
}
.cd-add:hover { transform: scale(1.06); }
.cd-add:active { transform: scale(.92); }
.cd-add .icon { width: 22px; height: 22px; }

/* Cards */
.cd-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--cd-radius-card);
  box-shadow: var(--cd-shadow-card); padding: var(--sp-5);
}
html[data-theme='dark'] .cd-card { border-width: 2px; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.cd-card-hover { transition: transform var(--cd-med) var(--cd-ease), box-shadow var(--cd-med) var(--cd-ease); }
.cd-card-hover:hover { transform: translateY(-4px); box-shadow: var(--cd-shadow-lift); }

/* Icon tile: white solid glyph on a rounded gradient square */
.cd-icon-tile {
  width: 56px; height: 56px; flex: none; display: grid; place-items: center;
  background: var(--cd-gradient); color: #fff; border-radius: var(--cd-radius-tile);
  box-shadow: 0 6px 16px rgba(230, 59, 31, .28);
}
.cd-icon-tile .icon { width: 28px; height: 28px; }
.cd-icon-tile-sm { width: 40px; height: 40px; border-radius: 14px; }
.cd-icon-tile-sm .icon { width: 22px; height: 22px; }

/* Chips (categories / tags / filters) */
.cd-chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 7px 16px;
  border-radius: var(--cd-radius-pill); border: 1.5px solid var(--border);
  background: var(--surface); color: var(--text); font-weight: 600; font-size: var(--fs-sm);
  text-decoration: none; white-space: nowrap; cursor: pointer;
  transition: background-color var(--cd-fast), border-color var(--cd-fast), transform var(--cd-fast);
}
.cd-chip:hover { border-color: var(--cd-orange); }
.cd-chip.is-active, .cd-chip[aria-pressed="true"], .cd-chip[aria-current] { background: var(--cd-gradient); border-color: transparent; color: var(--on-primary); }

/* Badges + order status badges */
.cd-badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: var(--cd-radius-pill);
  font-size: var(--fs-xs); font-weight: 700; letter-spacing: .02em; line-height: 1.5; white-space: nowrap;
  background: rgba(122, 58, 32, .1); color: var(--text-muted);
}
.cd-badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .9; }
.cd-badge.no-dot::before { display: none; }
.status-new        { background: rgba(255, 176, 46, .2);  color: var(--cd-status-new-ink); }
.status-accepted   { background: rgba(255, 106, 26, .16); color: var(--cd-status-accepted-ink); }
.status-preparing  { background: rgba(230, 59, 31, .14);  color: var(--cd-status-preparing-ink); }
.status-on-the-way { background: rgba(46, 139, 255, .14); color: var(--cd-status-on-the-way-ink); }
.status-delivered  { background: rgba(47, 168, 79, .15);  color: var(--cd-status-delivered-ink); }
.status-cancelled  { background: rgba(138, 111, 99, .18); color: var(--cd-status-cancelled-ink); }

/* Existing status classes from status_badge_class() mapped onto brand status colours:
   pending=New, accepted/confirmed=Accepted, preparing/ready=Preparing,
   out for delivery=On the way, delivered/completed=Delivered, cancelled/rejected=Cancelled */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: var(--cd-radius-pill);
  font-size: var(--fs-xs); font-weight: 700; letter-spacing: .02em; line-height: 1.5; white-space: nowrap;
}
.badge[class*="badge-"]::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .9; }
.badge.badge-pending        { background: rgba(255, 176, 46, .2);  color: var(--cd-status-new-ink); }
.badge.badge-accepted, .badge.badge-confirmed { background: rgba(255, 106, 26, .16); color: var(--cd-status-accepted-ink); }
.badge.badge-preparing, .badge.badge-ready    { background: rgba(230, 59, 31, .14);  color: var(--cd-status-preparing-ink); }
.badge.badge-outfordelivery { background: rgba(46, 139, 255, .14); color: var(--cd-status-on-the-way-ink); }
.badge.badge-delivered, .badge.badge-completed { background: rgba(47, 168, 79, .15);  color: var(--cd-status-delivered-ink); }
.badge.badge-cancelled, .badge.badge-rejected  { background: rgba(138, 111, 99, .18); color: var(--cd-status-cancelled-ink); }

/* Inputs */
.cd-input, .cd-select, .cd-textarea {
  width: 100%; min-height: 48px; padding: 12px 16px; border-radius: var(--cd-radius-input);
  border: 1.5px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: 500 var(--fs-md)/1.4 var(--font-ui); transition: border-color var(--cd-fast), box-shadow var(--cd-fast);
}
.cd-input::placeholder, .cd-textarea::placeholder { color: var(--text-soft); }
.cd-input:focus, .cd-select:focus, .cd-textarea:focus { outline: none; border-color: var(--cd-orange); box-shadow: 0 0 0 4px rgba(255, 106, 26, .22); }

/* Section header with the brand "swoosh" underline */
.cd-swoosh { position: relative; display: inline-block; padding-bottom: 10px; }
.cd-swoosh::after {
  content: ''; position: absolute; left: 0; bottom: 0; width: 64px; height: 5px; border-radius: 999px;
  background: var(--cd-gradient);
}
.cd-eyebrow { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-xs); font-weight: 700;
  letter-spacing: .14em; text-transform: uppercase; color: var(--link); }
.cd-gradient-text { background: var(--cd-gradient-soft); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* Skeleton loaders (cream/sand shimmer) */
.cd-skeleton { background: var(--skeleton); background-size: 200% 100%; animation: cd-shimmer 1.2s linear infinite; border-radius: 14px; }
@keyframes cd-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* Empty / error states */
.cd-empty { text-align: center; padding: var(--sp-7) var(--sp-5); }
.cd-empty .cd-icon-tile { margin: 0 auto var(--sp-4); }
.cd-empty h3 { font-size: var(--fs-xl); margin-bottom: 6px; }
.cd-empty p { color: var(--text-muted); max-width: 46ch; margin: 0 auto var(--sp-4); }

/* Dot pattern + glow decoration for hero/dark areas */
.cd-dots { background-image: radial-gradient(rgba(255, 176, 46, .18) 1px, transparent 1.4px); background-size: 22px 22px; }

/* Logo sizing (never stretched: width auto) */
.cd-logo { height: 44px; width: auto; display: block; }
.cd-app-icon { width: 40px; height: 40px; border-radius: 12px; display: block; }

/* Reduced motion: keep the UI, drop non-essential animation */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}
