/* =====================================================================
   Sirichaimongkol (Talad2) shared theme · v1 · 2026-11-24
   ONE file for every page: (1) tokens (verbatim from Sri's approved board,
   theme-tokens.css 2026-11-23), (2) self-hosted fonts (no CDN: the shop POS
   must work offline), (3) shared components (segmented quick-add bar).
   Pages link it with <link rel="stylesheet" href="theme/talad-theme.css?v=1">
   and map their own legacy variable names onto these tokens.
   ===================================================================== */

:root{
  color-scheme:light;

  /* ---- brand gradient stops ---- */
  --c1-emerald:#0B7A4B;          /* exact start (decorative) */
  --c1-teal:#0E8C99;             /* exact end (decorative) */
  --c1-emerald-ink:#086B45;      /* text-safe start: white = ~6.3:1 */
  --c1-teal-ink:#0A7D88;         /* text-safe end:   white = ~4.8:1 */
  --grad-fallback:#0B6F5A;       /* solid behind every gradient: white = ~6.1:1 */
  --on-grad:#FFFFFF;

  /* ---- gradient recipes ---- */
  --grad:linear-gradient(135deg,var(--c1-emerald),var(--c1-teal));
  --grad-ink:linear-gradient(135deg,var(--c1-emerald-ink),var(--c1-teal-ink));
  --grad-press:linear-gradient(135deg,#075C3B,#086B75);   /* :active state of gradient buttons */
  --grad-minus:color-mix(in srgb,var(--grad-fallback) 78%,#000); /* attached "–" segment on active pill */

  /* ---- neutrals ---- */
  --bg:#F4F6F9;
  --surface:#FFFFFF;
  --surface-2:#F1F4F8;
  --ink:#0F1B2A;
  --ink-2:#3A4757;
  --ink-3:#5D6B7B;
  --line:#E6EBF0;
  --line-2:#D5DDE6;

  /* ---- accent (solid, non-gradient uses: links, selected rows, focus) ---- */
  --accent:#0A6B42;
  --accent-wash:#E3F3EC;
  --focus-ring:0 0 0 3px var(--accent-wash);

  /* ---- status ---- */
  --ok:#1B7A45;   --ok-wash:#E1F3E8;
  --warn:#A85D00; --warn-wash:#FDEED8;   /* late (สาย) */
  --bad:#B3261E;  --bad-wash:#FBE4E2;    /* deductions / delete */

  /* ---- shadows ---- */
  --sh-1:0 1px 2px rgba(15,27,42,.05),0 8px 24px rgba(15,27,42,.06);   /* cards */
  --sh-2:0 2px 4px rgba(15,27,42,.05),0 16px 36px rgba(11,110,90,.14); /* floating: sheets, cart bar */
  --sh-3:0 30px 70px -20px rgba(0,0,0,.45);                            /* dialogs */
  --glow:0 8px 20px rgba(11,122,75,.28);                               /* gradient elements only */

  /* ---- typography: pairing #3 ---- */
  --font-head:"Mitr","Leelawadee UI","Thonburi","Tahoma",system-ui,sans-serif;
  --font-body:"K2D","Leelawadee UI","Thonburi","Tahoma",system-ui,sans-serif;
  --font-num:"DM Mono",ui-monospace,"SFMono-Regular","Menlo","Consolas",monospace; /* monospace = tabular baht */
  --fw-head:500;
  --fw-body:400;
  --fw-strong:600;
  --fw-num:500;
  --lh-tight:1.25;
  --lh-body:1.55;   /* Thai needs >= 1.5 */

  /* type scale (px) */
  --fs-display:32px;  /* shop wordmark, big screen titles */
  --fs-h1:24px;
  --fs-h2:20px;       /* header-band title, product name on edit */
  --fs-h3:17px;       /* product name in lists, section heads */
  --fs-body:16px;     /* inputs must stay 16px (no iOS zoom) */
  --fs-small:14px;
  --fs-caption:12px;
  --fs-money-xl:34px; /* hero total (DM Mono) */
  --fs-money-l:21px;  /* cart bar total */
  --fs-money:13px;    /* ledger cells */

  /* ---- spacing: 8px grid, 4px half-step ---- */
  --sp-0-5:4px;
  --sp-1:8px;
  --sp-1-5:12px;
  --sp-2:16px;        /* page gutter */
  --sp-3:24px;
  --sp-4:32px;
  --sp-6:48px;
  --tap-min:44px;     /* minimum tap target, every control */

  /* ---- radii ---- */
  --r-sm:6px;         /* tags, status chips */
  --r-md:10px;        /* inputs, segmented controls */
  --r-btn:12px;       /* buttons */
  --r-lg:14px;        /* cards, hero total, quick-add pills */
  --r-band:24px;      /* header band bottom corners */
  --r-pill:999px;

  /* ---- motion ---- */
  --ease-press:cubic-bezier(.3,.7,.4,1.4);
  --dur-press:120ms;  /* tap scale .94 */
  --dur-fly:650ms;    /* "+1" fly-to-cart; disable under prefers-reduced-motion */
}

/* ---------------- dark: follows the OS unless forced light ---------------- */
@media (prefers-color-scheme:dark){
  :root:not([data-theme="light"]){
    color-scheme:dark;
    /* gradient stops, --grad-fallback and --on-grad stay the same in dark */
    --bg:#0D1620;
    --surface:#16222E;
    --surface-2:#1C2B39;
    --ink:#E8EFF5;
    --ink-2:#B0C0CD;
    --ink-3:#8C9DAB;
    --line:#2A3B4A;
    --line-2:#36495A;
    --accent:#7FDCB2;
    --accent-wash:#173A2C;
    --ok:#4FC27E;   --ok-wash:#173826;
    --warn:#F0AA55; --warn-wash:#3A2A12;
    --bad:#F58C84;  --bad-wash:#3D1C1A;
    --sh-1:0 1px 2px rgba(0,0,0,.4),0 10px 28px rgba(0,0,0,.35);
    --sh-2:0 2px 4px rgba(0,0,0,.45),0 16px 36px rgba(0,0,0,.45);
    --sh-3:0 30px 70px -20px rgba(0,0,0,.8);
    --glow:0 8px 22px rgba(14,140,110,.35);
  }
}

/* ---------------- dark: forced by the in-app toggle ---------------- */
:root[data-theme="dark"]{
  color-scheme:dark;
  --bg:#0D1620;
  --surface:#16222E;
  --surface-2:#1C2B39;
  --ink:#E8EFF5;
  --ink-2:#B0C0CD;
  --ink-3:#8C9DAB;
  --line:#2A3B4A;
  --line-2:#36495A;
  --accent:#7FDCB2;
  --accent-wash:#173A2C;
  --ok:#4FC27E;   --ok-wash:#173826;
  --warn:#F0AA55; --warn-wash:#3A2A12;
  --bad:#F58C84;  --bad-wash:#3D1C1A;
  --sh-1:0 1px 2px rgba(0,0,0,.4),0 10px 28px rgba(0,0,0,.35);
  --sh-2:0 2px 4px rgba(0,0,0,.45),0 16px 36px rgba(0,0,0,.45);
  --sh-3:0 30px 70px -20px rgba(0,0,0,.8);
  --glow:0 8px 22px rgba(14,140,110,.35);
}

/* ---------------- fonts (self-hosted, SIL OFL 1.1, see theme/fonts/OFL.txt) ---------------- */
@font-face{font-family:"Mitr";font-style:normal;font-weight:500;font-display:swap;src:url(fonts/mitr-thai-500-normal.woff2) format("woff2");unicode-range:U+02D7,U+0303,U+0331,U+0E01-0E5B,U+200C-200D,U+25CC}
@font-face{font-family:"Mitr";font-style:normal;font-weight:500;font-display:swap;src:url(fonts/mitr-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:"K2D";font-style:normal;font-weight:400;font-display:swap;src:url(fonts/k2d-thai-400-normal.woff2) format("woff2");unicode-range:U+02D7,U+0303,U+0331,U+0E01-0E5B,U+200C-200D,U+25CC}
@font-face{font-family:"K2D";font-style:normal;font-weight:400;font-display:swap;src:url(fonts/k2d-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:"K2D";font-style:normal;font-weight:600;font-display:swap;src:url(fonts/k2d-thai-600-normal.woff2) format("woff2");unicode-range:U+02D7,U+0303,U+0331,U+0E01-0E5B,U+200C-200D,U+25CC}
@font-face{font-family:"K2D";font-style:normal;font-weight:600;font-display:swap;src:url(fonts/k2d-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:"K2D";font-style:normal;font-weight:700 900;font-display:swap;src:url(fonts/k2d-thai-700-normal.woff2) format("woff2");unicode-range:U+02D7,U+0303,U+0331,U+0E01-0E5B,U+200C-200D,U+25CC}
@font-face{font-family:"K2D";font-style:normal;font-weight:700 900;font-display:swap;src:url(fonts/k2d-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:"DM Mono";font-style:normal;font-weight:400;font-display:swap;src:url(fonts/dm-mono-latin-400-normal.woff2) format("woff2")}
@font-face{font-family:"DM Mono";font-style:normal;font-weight:500 900;font-display:swap;src:url(fonts/dm-mono-latin-500-normal.woff2) format("woff2")}

/* ---------------- shared: gradient surfaces (solid fallback painted first) ---------------- */
.t-grad{background-color:var(--grad-fallback);background-image:var(--grad-ink);color:var(--on-grad)}

/* ---------------- shared: segmented quick-add bar (Albert 2026-11-23, Option 2) ----------------
   One full-width bar per product, one segment per unit. Tap = +1 (the count shows in the
   segment), long-press = -1. No separate -/ลบ boxes (remove lives in the cart). Every
   segment >= --tap-min. The customer page uses the same bar with no price span.
   Every rule is scoped under .segbar: admin.html has its own older ".seg" (the 7/30-day switch). */
.segbar{display:flex;flex-wrap:wrap;width:100%;border:1px solid var(--line-2);border-radius:var(--r-md);
  background:var(--surface);overflow:hidden}
.segbar .seg{position:relative;flex:1 1 0;min-width:64px;min-height:52px;margin:0;padding:6px 4px;border:0;
  border-left:1px solid var(--line-2);background:transparent;color:var(--ink);
  display:flex;flex-direction:column;align-items:center;justify-content:center;gap:1px;text-align:center;
  font-family:var(--font-body);cursor:pointer;-webkit-user-select:none;user-select:none;
  -webkit-touch-callout:none;-webkit-tap-highlight-color:transparent;touch-action:manipulation;
  transition:background var(--dur-press),transform var(--dur-press) var(--ease-press)}
.segbar .seg:first-child{border-left:0}
.segbar .seg:active{background:var(--surface-2)}
.segbar .seg:focus-visible{outline:none;box-shadow:inset 0 0 0 2px var(--accent)}
.segbar .seg .sl{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;
  font-weight:var(--fw-strong);font-size:13px;line-height:1.2;overflow-wrap:anywhere}
.segbar .seg .sp{font-family:var(--font-num);font-weight:var(--fw-num);font-size:12px;color:var(--ink-3);line-height:1.2}
.segbar .seg .sc{position:absolute;top:3px;right:3px;min-width:22px;height:20px;padding:0 6px;border-radius:var(--r-pill);
  background:var(--grad-fallback);color:var(--on-grad);font-family:var(--font-num);font-size:12px;font-weight:500;
  line-height:20px;text-align:center;pointer-events:none}
.segbar .seg.on{background:var(--accent-wash)}
.segbar .seg.on .sl{color:var(--accent)}
.segbar .seg.bump{animation:t-bump 180ms var(--ease-press)}
@keyframes t-bump{50%{transform:scale(.94)}}
.seg-hint{grid-column:1/-1;font-size:var(--fs-caption);color:var(--ink-3);margin:-2px 2px 0}
@media (prefers-reduced-motion:reduce){.segbar .seg{transition:none}.segbar .seg.bump{animation:none}}

/* ---------------- shared: line icons (theme/icons.js swaps emoji for these; Albert 2026-11-24 "icons not emojis") ----------------
   .t-emo = one icon (svg + the original glyph kept for screen readers / text contracts in .t-sr, visually hidden, inline). */
/* !important: a page rule like ".pay-link span{display:none}" (hides a text label on phones) must never hide the injected icon;
   hiding the whole control/parent still hides it */
.t-emo{display:inline!important;white-space:nowrap}
.t-ic{display:inline-block!important;width:1.15em;height:1.15em;vertical-align:-.2em;flex:none;overflow:visible}
.t-sr{display:inline-block;width:1px;height:1px;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;vertical-align:top}
