/* Face Attendance — kiosk screen
 * The whole page is coloured by body[data-state]: idle · checking · ok · out · warn · err
 * (set by js/kiosk.js). Change the --c-* colours below to re-theme it. */
:root {
  --bg: #050912;
  --text: #eef4ff;
  --muted: #9aaccc;
  --dim: #5d6d8e;
  --glass: rgba(255, 255, 255, .055);
  --glass-hi: rgba(255, 255, 255, .09);
  --line: rgba(255, 255, 255, .11);

  --c-idle: #38bdf8;
  --c-checking: #a78bfa;
  --c-ok: #34d399;
  --c-out: #60a5fa;
  --c-warn: #fbbf24;
  --c-err: #fb7185;
  --accent: var(--c-idle);

  --radius: 28px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}
body[data-state="checking"] { --accent: var(--c-checking); }
body[data-state="ok"]       { --accent: var(--c-ok); }
body[data-state="out"]      { --accent: var(--c-out); }
body[data-state="warn"]     { --accent: var(--c-warn); }
body[data-state="err"]      { --accent: var(--c-err); }

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body.kiosk {
  background: radial-gradient(1200px 800px at 15% -10%, #0f1f3d 0%, transparent 60%),
              radial-gradient(1000px 700px at 110% 110%, #1a1240 0%, transparent 55%), var(--bg);
  color: var(--text);
  font-family: "Segoe UI Variable Display", "Segoe UI", "SF Pro Display", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  user-select: none;
}

/* ------------------------------------------------------------ aurora background
 * Soft radial gradients that only move (transform) — no blur filters or blend modes,
 * so cheap tablets keep their GPU for face detection. */
.aurora { position: fixed; inset: -20%; z-index: 0; pointer-events: none; overflow: hidden; }
.aurora span { position: absolute; border-radius: 50%; will-change: transform; animation: drift 26s ease-in-out infinite alternate; }
.aurora span:nth-child(1) { width: 70vmax; height: 70vmax; top: -10%; left: -10%; background: radial-gradient(circle, rgba(14, 165, 233, .30), transparent 62%); }
.aurora span:nth-child(2) { width: 64vmax; height: 64vmax; right: -10%; bottom: -10%; background: radial-gradient(circle, rgba(124, 58, 237, .28), transparent 62%); animation-duration: 32s; animation-delay: -8s; }
.aurora span:nth-child(3) { width: 52vmax; height: 52vmax; left: 30%; top: 22%; opacity: .22;
  background: radial-gradient(circle, var(--accent), transparent 62%); animation-duration: 20s; animation-delay: -4s; }
@keyframes drift {
  0%   { transform: translate(0, 0) scale(1); }
  50%  { transform: translate(9vmax, 5vmax) scale(1.15); }
  100% { transform: translate(-6vmax, 7vmax) scale(.92); }
}

/* ------------------------------------------------------------ layout */
.k-shell {
  position: relative; z-index: 1; height: 100vh; height: 100dvh;
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto;
  gap: clamp(12px, 1.8vw, 22px); padding: clamp(14px, 2.2vw, 30px);
}
.k-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.k-brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.k-logo {
  width: 48px; height: 48px; flex: 0 0 auto; border-radius: 15px; display: grid; place-items: center;
  font-weight: 800; font-size: 18px; letter-spacing: .02em;
  background: linear-gradient(135deg, #22d3ee, #6366f1 55%, #a855f7);
  box-shadow: 0 10px 30px rgba(99, 102, 241, .45), inset 0 1px 0 rgba(255, 255, 255, .35);
}
.k-brand-text b { display: block; font-size: clamp(17px, 1.6vw, 21px); font-weight: 700; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.k-brand-text small { color: var(--muted); font-size: 13px; letter-spacing: .04em; }
.k-clock { text-align: right; }
.k-time { font-size: clamp(36px, 4.6vw, 64px); font-weight: 700; line-height: 1; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.k-sec { font-size: .4em; color: var(--muted); font-weight: 600; margin-left: 4px; letter-spacing: 0; }
.k-date { color: var(--muted); font-size: clamp(13px, 1.1vw, 15px); margin-top: 6px; letter-spacing: .02em; }

.k-main { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(340px, 1fr); gap: clamp(14px, 1.8vw, 24px); min-height: 0; }

/* ------------------------------------------------------------ camera stage */
.k-stage {
  position: relative; border-radius: var(--radius); overflow: hidden; isolation: isolate; min-height: 0;
  background: radial-gradient(circle at 50% 45%, #0b1630, #03060d 70%);
  border: 1px solid var(--line);
  box-shadow: 0 40px 90px rgba(0, 0, 0, .55);
}
.k-stage::after {   /* state-coloured inner glow */
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: 4;
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--accent) 40%, transparent),
              inset 0 0 90px color-mix(in srgb, var(--accent) 22%, transparent);
  transition: box-shadow .5s var(--ease);
}
.k-stage video, .k-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.k-stage canvas { z-index: 2; pointer-events: none; }
.k-vignette { position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(3, 6, 13, .65) 100%); }

/* face guide: four sharp corner brackets + scan line */
.k-guide {
  position: absolute; z-index: 3; left: 50%; top: 50%; width: min(44%, 340px); aspect-ratio: 3 / 4;
  transform: translate(-50%, -50%); pointer-events: none; will-change: transform; animation: breathe 3.2s ease-in-out infinite;
}
.k-guide .c {
  position: absolute; width: 24%; aspect-ratio: 1; border: 4px solid var(--accent);
  filter: drop-shadow(0 0 10px var(--accent)); transition: border-color .4s, transform .5s var(--ease), filter .4s;
}
.k-guide .tl { top: 0; left: 0; border-right: 0; border-bottom: 0; border-top-left-radius: 26px; }
.k-guide .tr { top: 0; right: 0; border-left: 0; border-bottom: 0; border-top-right-radius: 26px; }
.k-guide .bl { bottom: 0; left: 0; border-right: 0; border-top: 0; border-bottom-left-radius: 26px; }
.k-guide .br { bottom: 0; right: 0; border-left: 0; border-top: 0; border-bottom-right-radius: 26px; }
.k-scan {
  position: absolute; left: 7%; right: 7%; height: 3px; top: 10%; border-radius: 3px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  box-shadow: 0 0 18px 2px color-mix(in srgb, var(--accent) 70%, transparent);
  animation: scan 2.6s ease-in-out infinite;
}
@keyframes scan { 0%, 100% { top: 8%; opacity: .25; } 50% { top: 90%; opacity: 1; } }
@keyframes breathe { 0%, 100% { transform: translate(-50%, -50%) scale(1); } 50% { transform: translate(-50%, -50%) scale(1.035); } }

body[data-state="checking"] .k-scan { animation-duration: .9s; }
body[data-state="ok"] .k-guide, body[data-state="out"] .k-guide { animation: none; }
body[data-state="ok"] .k-guide .tl, body[data-state="out"] .k-guide .tl { transform: translate(14%, 14%); }
body[data-state="ok"] .k-guide .tr, body[data-state="out"] .k-guide .tr { transform: translate(-14%, 14%); }
body[data-state="ok"] .k-guide .bl, body[data-state="out"] .k-guide .bl { transform: translate(14%, -14%); }
body[data-state="ok"] .k-guide .br, body[data-state="out"] .k-guide .br { transform: translate(-14%, -14%); }
body[data-state="ok"] .k-scan, body[data-state="out"] .k-scan { opacity: 0; animation: none; }
body[data-state="err"] .k-guide { animation: shake .45s ease; }
@keyframes shake { 0%, 100% { transform: translate(-50%, -50%); } 20%, 60% { transform: translate(-53%, -50%); } 40%, 80% { transform: translate(-47%, -50%); } }

/* success burst */
.k-ripple { position: absolute; z-index: 3; left: 50%; top: 50%; width: 30%; aspect-ratio: 1; border-radius: 50%;
  transform: translate(-50%, -50%) scale(0); border: 3px solid var(--accent); opacity: 0; pointer-events: none; }
.k-ripple.go { animation: ripple .9s var(--ease); }
@keyframes ripple { 0% { transform: translate(-50%, -50%) scale(.2); opacity: .9; } 100% { transform: translate(-50%, -50%) scale(3.2); opacity: 0; } }

/* live status tag on the camera */
.k-tag {
  position: absolute; z-index: 5; left: 18px; top: 18px; display: inline-flex; align-items: center; gap: 9px;
  padding: 8px 14px 8px 12px; border-radius: 999px; font-size: 13.5px; font-weight: 600; letter-spacing: .02em;
  background: rgba(5, 9, 18, .72); border: 1px solid var(--line);
}
.k-tag-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 0 var(--accent); animation: pulse 1.8s infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 70%, transparent); }
  70% { box-shadow: 0 0 0 10px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* ------------------------------------------------------------ result panel */
.k-panel { display: flex; flex-direction: column; gap: clamp(14px, 1.8vw, 24px); min-height: 0; }
.k-result {
  position: relative; flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column; justify-content: center;
  padding: clamp(26px, 3.2vw, 48px); border-radius: var(--radius);
  background: linear-gradient(160deg, rgba(30, 41, 66, .82), rgba(14, 20, 36, .78));
  border: 1px solid var(--line);
  box-shadow: 0 30px 70px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 255, 255, .08);
}
.k-result::before {  /* state glow in the corner */
  content: ""; position: absolute; width: 70%; aspect-ratio: 1; right: -25%; top: -35%; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, color-mix(in srgb, var(--accent) 35%, transparent), transparent 70%);
  transition: background .6s var(--ease);
}
.k-badge {
  width: clamp(66px, 7vw, 96px); aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; margin-bottom: clamp(16px, 2vw, 26px);
  color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent);
  border: 2px solid color-mix(in srgb, var(--accent) 55%, transparent);
  box-shadow: 0 0 50px color-mix(in srgb, var(--accent) 35%, transparent);
  transition: color .4s, background .4s, border-color .4s, box-shadow .4s;
}
.k-badge svg { width: 56%; height: 56%; fill: none; stroke: currentColor; stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; }
.k-badge .draw { stroke-dasharray: 80; stroke-dashoffset: 80; animation: draw .7s .12s var(--ease) forwards; }
.k-badge .spin { transform-origin: 26px 26px; animation: spin .9s linear infinite; stroke-dasharray: 60 30; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
body[data-state="ok"] .k-badge, body[data-state="out"] .k-badge { animation: pop .5s var(--ease); }
@keyframes pop { 0% { transform: scale(.6); } 60% { transform: scale(1.08); } 100% { transform: scale(1); } }

.k-eyebrow { font-size: 13px; font-weight: 800; letter-spacing: .2em; text-transform: uppercase; color: var(--accent); transition: color .4s; }
.k-result h1 { font-size: clamp(34px, 4.3vw, 62px); line-height: 1.04; letter-spacing: -.035em; font-weight: 750; margin: 10px 0 14px; overflow-wrap: anywhere; }
.k-sub { font-size: clamp(16px, 1.45vw, 20px); line-height: 1.5; color: var(--muted); margin: 0; max-width: 34ch; }
.k-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.k-chips:empty { display: none; }
.k-chip { padding: 8px 14px; border-radius: 999px; font-size: 14.5px; font-weight: 650; background: rgba(255, 255, 255, .07); border: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.k-chip.accent { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.k-meta { margin-top: 14px; font-size: 13px; color: var(--dim); letter-spacing: .02em; }
.k-meta:empty { display: none; }
.k-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(255, 255, 255, .05); }
.k-progress i { display: block; height: 100%; width: 0; background: var(--accent); box-shadow: 0 0 14px var(--accent); }

/* text swap animation (restarted by JS on every new message) */
.k-result.swap .k-anim { animation: rise .55s var(--ease) both; animation-delay: calc(var(--i) * 55ms); }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

/* just-marked list */
.k-recent {
  padding: 18px 20px; border-radius: 22px; background: rgba(14, 20, 36, .72); border: 1px solid var(--line);
}
.k-recent h4 { margin: 0 0 10px; font-size: 12px; letter-spacing: .18em; text-transform: uppercase; color: var(--dim); font-weight: 800; }
.k-recent ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.k-recent li { display: flex; align-items: center; gap: 12px; font-size: 15px; }
.k-recent li.new { animation: slidein .5s var(--ease); }
@keyframes slidein { from { opacity: 0; transform: translateX(-14px); } to { opacity: 1; transform: none; } }
.k-recent .av { width: 34px; height: 34px; flex: 0 0 auto; border-radius: 50%; display: grid; place-items: center; font-size: 12.5px; font-weight: 800;
  background: color-mix(in srgb, var(--k) 20%, transparent); color: var(--k); border: 1px solid color-mix(in srgb, var(--k) 45%, transparent); }
.k-recent .nm { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.k-recent .kd { font-size: 11.5px; font-weight: 800; letter-spacing: .08em; color: var(--k); }
.k-recent .tm { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 14px; }
.k-recent .k-empty { color: var(--dim); font-size: 14px; }

/* ------------------------------------------------------------ footer */
.k-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 13px; color: var(--dim); }
.k-status { display: flex; align-items: center; gap: 8px; }
.k-pill { display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px; border-radius: 999px; background: var(--glass); border: 1px solid var(--line); color: var(--muted); font-weight: 600; }
.k-pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--c-ok); }
.k-pill.off i { background: var(--dim); }
.k-pill.bad { color: var(--c-err); border-color: color-mix(in srgb, var(--c-err) 45%, transparent); }
.k-pill.bad i { background: var(--c-err); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .2; } }

/* ------------------------------------------------------------ start screen */
.k-start {
  position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 24px;
  background: rgba(3, 6, 13, .78); backdrop-filter: blur(8px);
  transition: opacity .6s var(--ease), visibility .6s;
}
.k-start.hidden { opacity: 0; visibility: hidden; }
.k-start-card {
  width: min(500px, 100%); text-align: center; padding: clamp(30px, 4vw, 46px); border-radius: 32px;
  background: linear-gradient(160deg, rgba(255, 255, 255, .1), rgba(255, 255, 255, .04)); border: 1px solid var(--line);
  box-shadow: 0 40px 100px rgba(0, 0, 0, .5); animation: rise .7s var(--ease) both;
}
.k-start-logo { position: relative; width: 96px; height: 96px; margin: 0 auto 22px; display: grid; place-items: center; }
.k-start-logo span { position: absolute; inset: 0; border-radius: 50%; padding: 3px;
  background: conic-gradient(from 0deg, #22d3ee, #6366f1, #a855f7, #22d3ee);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude;
  animation: spin 3s linear infinite; }
.k-start-logo svg { width: 54px; height: 54px; fill: none; stroke: #c7d2fe; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.k-start h1 { margin: 0 0 10px; font-size: clamp(26px, 3vw, 34px); letter-spacing: -.03em; }
.k-start p { margin: 0 0 22px; color: var(--muted); font-size: 16px; line-height: 1.5; }
.k-steps { list-style: none; padding: 0; margin: 0 auto 26px; display: grid; gap: 10px; text-align: left; width: fit-content; min-width: 240px; }
.k-steps li { display: flex; align-items: center; gap: 12px; color: var(--dim); font-weight: 600; font-size: 15px; transition: color .3s; }
.k-steps li i { width: 22px; height: 22px; border-radius: 50%; border: 2px solid currentColor; flex: 0 0 auto; display: grid; place-items: center; font-style: normal; font-size: 12px; }
.k-steps li.active { color: var(--c-idle); }
.k-steps li.active i { border-color: transparent; border-top-color: currentColor; border-right-color: currentColor; animation: spin .8s linear infinite; }
.k-steps li.done { color: var(--c-ok); }
.k-steps li.done i { background: var(--c-ok); border-color: var(--c-ok); color: #052e1c; }
.k-steps li.done i::after { content: "✓"; font-weight: 900; }
.k-steps li.fail { color: var(--c-err); }
.k-steps li.fail i::after { content: "!"; font-weight: 900; }
.k-btn {
  position: relative; border: 0; cursor: pointer; padding: 16px 40px; border-radius: 16px; font: inherit; font-size: 17px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, #0ea5e9, #6366f1 60%, #a855f7);
  box-shadow: 0 14px 34px rgba(99, 102, 241, .45), inset 0 1px 0 rgba(255, 255, 255, .3);
  transition: transform .15s var(--ease), box-shadow .2s, opacity .2s;
}
.k-btn:not(:disabled) { animation: glow 2.4s ease-in-out infinite; }
.k-btn:hover:not(:disabled) { transform: translateY(-2px); }
.k-btn:active:not(:disabled) { transform: scale(.97); }
.k-btn:disabled { opacity: .45; cursor: default; }
@keyframes glow { 0%, 100% { box-shadow: 0 14px 34px rgba(99, 102, 241, .45), 0 0 0 0 rgba(99, 102, 241, .5); } 50% { box-shadow: 0 14px 34px rgba(99, 102, 241, .45), 0 0 0 12px rgba(99, 102, 241, 0); } }

/* ------------------------------------------------------------ portrait tablets / phones */
@media (max-aspect-ratio: 1/1), (max-width: 900px) {
  body.kiosk { overflow: auto; }
  .k-main { grid-template-columns: 1fr; grid-template-rows: minmax(260px, 1.25fr) auto; }
  .k-result { justify-content: flex-start; }
  .k-sub { max-width: none; }
}
@media (max-aspect-ratio: 1/1) and (max-height: 1000px), (max-width: 600px) {
  .k-recent { display: none; }
  .k-tip { display: none; }
}
@media (max-width: 600px) {
  .k-shell { height: auto; min-height: 100dvh; }
  .k-main { grid-template-rows: 58vh auto; }
  .k-brand-text small, .k-ver { display: none; }
  .k-tag { left: 12px; top: 12px; }
}

/* ------------------------------------------------------------ reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .aurora { display: none; }
  .k-badge .draw { stroke-dashoffset: 0; }
}
