/* In-Sign (ISL) design tokens · v1.3 · 24 Nov 2026 (v1 7 Nov 2026; v1.3 adds Andrew's 24 Nov "Go" on review gaps G2 and G10)
   Source of truth: 07_Admin/Brand/DESIGN_BOOK.md.
   The standard is the live clock-in page (clockin.insign.com.hk) and the A4 site QR poster,
   both approved by Andrew on 7 Nov 2026. Every ISL page and document uses these names.
   Light is the default and the only mode on the staff clock-in page (Andrew 31 Oct 2026:
   "the new design ok, the white go grey a bit"). Dark tokens exist for office pages that opt in. */

:root {
  /* ---- Brand (from the letterhead; never tinted, never used as text on a coloured ground) ---- */
  --isl-red:   #EB3D00;   /* "in-" outline · problems / errors ONLY */
  --isl-green: #009049;   /* "sign" outline · 上班 IN · at site · success */
  --isl-blue:  #0089E1;   /* "limited" · 下班 OUT · step numbers · links */
  --isl-grey:  #747D82;   /* Chinese name, seal, rule line · secondary headings */

  /* ---- Surfaces (light, the default) ---- */
  --bg:    #E9EBED;       /* page: grey-white, cuts sun glare */
  --card:  #F4F5F6;       /* cards, header, inputs */
  --soft:  #E2E5E8;       /* pressed / selected background */
  --line:  #D3D8DB;       /* 1px borders and rules */
  --ink:   #2B3134;       /* body text, titles, dark buttons */
  --muted: #5F676C;       /* captions, English under Chinese, times. Was #6F777C (4.18 : 1 on card); now 5.28 on card, 4.82 on page (24 Nov) */

  /* ---- Roles ---- */
  --in:    var(--isl-green);
  --out:   var(--isl-blue);
  --ok:    var(--isl-green);
  --warn:  #A15C00;       /* amber dark enough to read in sun (not the brand red) */
  --info:  #2A5D9F;       /* information navy: site notices, notice board, info pills, job-code tags (Andrew 10 Nov 2026) */
  --info-tint: #EEF3F8;   /* its one tint */
  --info-line: #C3D3E4;   /* its one border */
  --bad:   var(--isl-red);
  --link:  #006BB0;       /* link TEXT: 5.16 on card, 4.71 on page (Andrew 24 Nov via FIN head, "Your recom"); was #0089E1 at 3.40 */
  --out-text: #006BB0;    /* 下班 / OUT as words at normal size; fills, the big OUT button and the focus ring keep #0089E1 */
  --rule:  var(--isl-grey);
  --on-colour: #FFFFFF;   /* text on green / blue / red / ink buttons */

  /* text colours for light mode (24 Nov, G2): the bright brand colours stay for fills, bars, borders and big type
     (24 px bold and up); words in red or green at normal size use these, at least 4.5 : 1 on card and page */
  --bad-text: #C23200;    /* 5.13 on card, 4.69 on page */
  --ok-text:  #00783C;    /* 5.13 on card, 4.68 on page; also IN / 上班 as words */
  --in-text:  var(--ok-text);
  /* fills for SMALL buttons with white text under 24 px (white on the bright green is only 4.13) */
  --in-strong:  #00783C;  /* white on it 5.60 */
  --out-strong: #006BB0;  /* white on it 5.63 */
  /* the two big IN / OUT buttons (26 px bold) keep --in / --out: large text, 4.13 and 3.71 pass the 3 : 1 rule */

  /* disabled (24 Nov, G10): readable, not white on #C6CCD0 (1.62) */
  --disabled-bg:   #E2E5E8; /* = --soft */
  --disabled-ink:  #5F676C; /* 4.56 on it */
  --disabled-line: #D3D8DB;
  --disabled: #C6CCD0;    /* OLD, kept only until pages move to --disabled-bg / --disabled-ink; do not use in new work */

  /* one focus ring everywhere (24 Nov, G10) */
  --focus: #0089E1;       /* 3.40 on card, 3.10 on page: passes the 3 : 1 rule for outlines */
  --focus-w: 2px;
  --focus-gap: 2px;

  /* tints for status boxes (page stays light; a tinted card + solid border) */
  --ok-tint:   color-mix(in srgb, var(--isl-green) 12%, var(--card));
  --warn-tint: color-mix(in srgb, var(--warn) 14%, var(--card));
  --bad-tint:  color-mix(in srgb, var(--isl-red) 12%, var(--card));

  /* ---- Type ---- */
  --font: -apple-system, "Segoe UI", Roboto, "Noto Sans HK", "PingFang HK", "Microsoft JhengHei", sans-serif;
  --font-print-zh: "Microsoft JhengHei", "Noto Sans HK", "PingFang HK", sans-serif; /* posters, letters */
  --font-print-en: Arial, Helvetica, sans-serif;
  --fs-caption: 13px;   /* English under Chinese, times, tags */
  --fs-body:    16px;   /* phone body (office pages may use 15px) */
  --fs-title:   18px;   /* card title, dialog title */
  --fs-site:    20px;   /* site name, person name */
  --fs-result:  24px;   /* "✓ 已上班 07:58" */
  --fs-go:      26px;   /* the IN / OUT button */
  --lh: 1.4;

  /* ---- Shape & space ---- */
  --radius:      8px;   /* cards, buttons, inputs */
  --radius-chip: 18px;  /* chips */
  --radius-pill: 999px; /* status pills */
  --radius-box:  10px;  /* status boxes, pop-ups */
  --tap:   44px;        /* minimum tap target */
  --go-h:  76px;        /* IN / OUT button height (glove-friendly) */
  --gutter: 14px;       /* side padding on phone */
  --gap: 8px;
  --maxw: 520px;        /* phone column width */
  --rule-w: 3px;        /* grey rule under the header; status box left bars */

  /* ---- Logo ---- */
  --logo-h: 32px;       /* wordmark height in the phone header */
  --logo-h-min: 24px;   /* never smaller on screen */

  color-scheme: light;
}

/* Dark mode: defined for office pages that opt in with data-theme="dark".
   The staff clock-in page and the guide stay light (sun readability, Andrew 31 Oct). */
:root[data-theme="dark"] {
  --bg:    #1F2426;
  --card:  #2B3134;
  --soft:  #343B3F;
  --line:  #46505A;
  --ink:   #EEF1F3;
  --muted: #AEB6BC;
  --warn:  #E6A23C;
  --disabled: #5A636A;
  --ok-tint:   color-mix(in srgb, var(--isl-green) 22%, var(--card));
  --warn-tint: color-mix(in srgb, var(--warn) 20%, var(--card));
  --bad-tint:  color-mix(in srgb, var(--isl-red) 22%, var(--card));
  color-scheme: dark;
}

/* ---- Base component recipes (copy, do not reinvent) ---- */
.isl-body { margin: 0; background: var(--bg); color: var(--ink); font: var(--fs-body)/var(--lh) var(--font); font-variant-numeric: tabular-nums; }
.isl-header { display: flex; align-items: center; gap: 10px; padding: 7px var(--gutter) 6px; background: var(--card); border-bottom: var(--rule-w) solid var(--rule); }
.isl-header .logo { height: var(--logo-h); display: block; }
.isl-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin: 0 0 10px; }
.isl-go { display: block; width: 100%; min-height: var(--go-h); padding: 18px 14px; border: 0; border-radius: var(--radius); font: 700 var(--fs-go)/1.1 var(--font); color: var(--on-colour); cursor: pointer; }
.isl-go.in { background: var(--in); } .isl-go.out { background: var(--out); } .isl-go:disabled { background: var(--disabled-bg); color: var(--disabled-ink); box-shadow: inset 0 0 0 1px var(--disabled-line); }
.isl-go small { display: block; font-size: 14px; font-weight: 600; opacity: .85; margin-top: 2px; }
.isl-btn { display: block; width: 100%; min-height: var(--tap); padding: 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); color: var(--ink); font: 700 15px var(--font); cursor: pointer; }
.isl-btn.primary { background: var(--ink); color: var(--on-colour); border-color: var(--ink); }
.isl-btn.in { background: var(--in-strong); color: var(--on-colour); border-color: var(--in-strong); } .isl-btn.out { background: var(--out-strong); color: var(--on-colour); border-color: var(--out-strong); }
.isl-btn:disabled, .isl-btn.primary:disabled, .isl-btn.in:disabled, .isl-btn.out:disabled { background: var(--disabled-bg); color: var(--disabled-ink); border-color: var(--disabled-line); cursor: not-allowed; }
.isl-chip { display: inline-flex; align-items: center; gap: 5px; min-height: 36px; padding: 6px 11px; border: 1px solid var(--line); border-radius: var(--radius-chip); background: var(--card); color: var(--ink); font: 14px var(--font); }
.isl-chip.on { background: var(--ink); color: var(--on-colour); border-color: var(--ink); }
.isl-pill { font-size: 13px; padding: 2px 8px; border-radius: var(--radius-pill); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.isl-pill.ok { color: var(--ok-text); border-color: var(--ok); } .isl-pill.wait { color: var(--warn); border-color: var(--warn); } .isl-pill.bad { color: var(--bad-text); border-color: var(--bad); }
.isl-box { border-radius: var(--radius-box); padding: 9px 11px; margin: 0 0 8px; font-size: 14px; line-height: 1.45; border: 1px solid var(--line); background: var(--card); }
.isl-box.ok { border-color: var(--ok); } .isl-box.warn { background: var(--warn-tint); border-color: var(--warn); } .isl-box.bad { background: var(--bad-tint); border-color: var(--bad); }
.isl-note { border-left: var(--rule-w) solid var(--warn); background: var(--card); padding: 8px 10px; border-radius: 4px; margin: 0 0 10px; font-size: 14px; }
.isl-err  { border-left: var(--rule-w) solid var(--bad);  background: var(--card); padding: 8px 10px; border-radius: 4px; margin: 0 0 10px; font-size: 14px; }
.isl-result { border: 1px solid var(--line); border-radius: var(--radius-box); background: var(--card); padding: 14px 12px; text-align: center; }
.isl-result .big1 { font-size: var(--fs-result); font-weight: 800; }
.isl-result.in .big1 { color: var(--in); } .isl-result.out .big1 { color: var(--out); } .isl-result.bad .big1 { color: var(--bad); }
.isl-kin { color: var(--in-text); font-weight: 700; } .isl-kout { color: var(--out-text); font-weight: 700; } .isl-kbad { color: var(--bad-text); font-weight: 700; } .isl-kwarn { color: var(--warn); font-weight: 700; }
.isl-zh-en { display: block; } .isl-zh-en small { display: block; font-size: var(--fs-caption); color: var(--muted); font-weight: 400; }
.isl-tricolour { height: 6px; background: linear-gradient(90deg, var(--isl-red) 0 33.3%, var(--isl-green) 33.3% 66.6%, var(--isl-blue) 66.6%); } /* print only */
button, .isl-chip { touch-action: manipulation; -webkit-tap-highlight-color: transparent; transition: transform .07s, filter .07s; }
button:not(:disabled):active { transform: scale(.97); filter: brightness(.88); }

/* ---- Forms (24 Nov 2026, G10; DESIGN_BOOK.md §14) ---- */
.isl-field { display: block; margin: 0 0 12px; }
.isl-field > .lbl { display: block; font-size: var(--fs-caption); color: var(--muted); margin: 0 0 4px; }
.isl-input, .isl-select, input.isl-date { display: block; width: 100%; box-sizing: border-box; min-height: var(--tap); padding: 9px 11px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); color: var(--ink);
  font: 400 16px/1.3 var(--font); } /* 16 px stops the iPhone zooming in */
.isl-input::placeholder { color: var(--muted); }
.isl-input[aria-invalid="true"] { border-color: var(--bad); }
.isl-field > .err { display: block; font-size: 14px; color: var(--bad-text); margin: 4px 0 0; }
.isl-input:disabled, .isl-select:disabled { background: var(--disabled-bg); color: var(--disabled-ink); border-color: var(--disabled-line); }
/* two-way switch: two buttons side by side; the chosen one follows §13.8 (2 px green border + green tint) */
.isl-seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.isl-seg > button { min-height: var(--tap); border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); color: var(--ink); font: 400 15px var(--font); }
.isl-seg > button[aria-pressed="true"] { border: 2px solid var(--in); background: var(--ok-tint); color: var(--ink); font-weight: 700; }
/* on / off toggle: the whole row is the tap target; off = brand grey, on = green */
.isl-toggle { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; min-height: 48px; padding: 4px 0;
  background: none; border: 0; border-top: 1px solid var(--line); text-align: left; color: var(--ink); font: 700 15px var(--font); }
.isl-toggle .tg { flex: none; width: 50px; height: 30px; border-radius: 15px; background: var(--rule); position: relative; }
.isl-toggle .tg::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #FFFFFF; transition: left .15s; }
.isl-toggle[aria-checked="true"] .tg { background: var(--in); } .isl-toggle[aria-checked="true"] .tg::after { left: 23px; }
/* tick rows: a 24 px box, the whole row is the label and the tap target */
.isl-tick { display: flex; align-items: center; gap: 10px; min-height: var(--tap); font-size: 15px; cursor: pointer; }
.isl-tick input { width: 24px; height: 24px; margin: 0; accent-color: var(--in); flex: none; }
/* menus: a floating layer (one soft shadow allowed, §13.1); items 44 px; Esc closes and focus goes back to the button */
.isl-menu { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-box); box-shadow: 0 8px 24px rgba(20,24,27,.18); padding: 4px 0; }
.isl-menu [role="menuitem"] { display: flex; align-items: center; min-height: var(--tap); padding: 0 12px; width: 100%; background: none; border: 0; text-align: left; font: 400 15px var(--font); color: var(--ink); }
.isl-menu [role="menuitem"]:hover, .isl-menu [role="menuitem"][aria-selected="true"] { background: var(--soft); }
/* one focus ring for every control, keyboard focus only */
:where(button, a, input, select, textarea, [tabindex], [role="menuitem"]):focus-visible { outline: var(--focus-w) solid var(--focus); outline-offset: var(--focus-gap); }
