/* HRIS Bosowa — Atmospheric Glass
   Glassmorphism: frosted layers over vibrant gradient field.
   Tokens from design spec: Inter, 8px grid, radius lg=16 / xl=24. */

:root {
  /* surface ramp (dark, off-black — never #000) */
  --surface:          #0b1326;
  --surface-low:      #131b2e;
  --surface-container:#171f33;
  --surface-high:     #222a3d;

  /* on-surface */
  --on-surface:       #dae2fd;
  --on-variant:       #c4c7c8;
  --outline:          rgba(255, 255, 255, 0.2);
  --outline-soft:     rgba(255, 255, 255, 0.1);

  /* accents */
  --blue:   #0080ff;
  --purple: #8b00ff;
  --pink:   #ff1493;
  --teal:   #20b2aa;
  --secondary: #adc9eb;

  /* glass */
  --glass-1: rgba(255, 255, 255, 0.10);
  --glass-2: rgba(255, 255, 255, 0.16);
  --glass-3: rgba(255, 255, 255, 0.22);
  --shade:   rgba(0, 0, 0, 0.28);
  --blur-1: 20px;
  --blur-2: 40px;
  --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.30);

  /* radius */
  --r-sm: 0.25rem;
  --r:    0.5rem;
  --r-md: 0.75rem;
  --r-lg: 1rem;
  --r-xl: 1.5rem;
  --r-full: 9999px;

  /* rhythm 8px */
  --u: 8px;

  --txt-shadow: 0 2px 4px rgba(0, 0, 0, 0.22);
  --ease: cubic-bezier(.22, .61, .36, 1);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; padding: 0; }

body {
  min-height: 100dvh;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--on-surface);
  background: var(--surface);
  padding: 0 0 calc(var(--u) * 4 + env(safe-area-inset-bottom));
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── atmospheric field ─────────────────────────────────────────────── */
.atmos {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 12% 0%,  #1e3a8a 0%, transparent 55%),
    radial-gradient(110% 85% at 88% 8%,  #7e22ce 0%, transparent 52%),
    radial-gradient(120% 100% at 50% 110%, #db2777 0%, transparent 58%),
    linear-gradient(168deg, #060e20 0%, #0b1326 46%, #140b24 100%);
}
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.55;
  will-change: transform;
}
.orb-a {
  width: 46vmax; height: 46vmax; top: -14vmax; left: -10vmax;
  background: radial-gradient(circle, var(--blue) 0%, transparent 66%);
  animation: drift-a 26s var(--ease) infinite alternate;
}
.orb-b {
  width: 40vmax; height: 40vmax; top: 18vmax; right: -14vmax;
  background: radial-gradient(circle, var(--purple) 0%, transparent 66%);
  animation: drift-b 32s var(--ease) infinite alternate;
  opacity: 0.45;
}
.orb-c {
  width: 38vmax; height: 38vmax; bottom: -16vmax; left: 14vmax;
  background: radial-gradient(circle, var(--pink) 0%, transparent 68%);
  animation: drift-c 29s var(--ease) infinite alternate;
  opacity: 0.38;
}
.grain {
  position: absolute; inset: 0; opacity: 0.035; pointer-events: none;
  background-image: url("data:image/svg+xml;utf8,\
<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'>\
<filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/></filter>\
<rect width='120' height='120' filter='url(%23n)'/></svg>");
}
@keyframes drift-a { to { transform: translate3d(6vmax, 4vmax, 0) scale(1.08); } }
@keyframes drift-b { to { transform: translate3d(-5vmax, 6vmax, 0) scale(1.06); } }
@keyframes drift-c { to { transform: translate3d(4vmax, -5vmax, 0) scale(1.1); } }

/* ── topbar ────────────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: calc(var(--u) * 2);
  padding: calc(var(--u) * 1.75 + env(safe-area-inset-top)) calc(var(--u) * 2.5) calc(var(--u) * 1.75);
  background: rgba(11, 19, 38, 0.55);
  -webkit-backdrop-filter: blur(var(--blur-1)) saturate(150%);
  backdrop-filter: blur(var(--blur-1)) saturate(150%);
  border-bottom: 1px solid var(--outline-soft);
}
.brand { display: flex; align-items: center; gap: calc(var(--u) * 1.5); min-width: 0; }
.mark { width: 26px; height: 26px; color: var(--secondary); flex: none; }
.brandtext { min-width: 0; }
.topbar h1 {
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.25;
  text-shadow: var(--txt-shadow);
}
.sub {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--on-variant);
}

/* ── layout ────────────────────────────────────────────────────────── */
main {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: calc(var(--u) * 2);
  max-width: 520px;
  margin: 0 auto;
  padding: calc(var(--u) * 3) calc(var(--u) * 2.5) calc(var(--u) * 5);
}

/* ── glass card ────────────────────────────────────────────────────── */
.card {
  position: relative;
  background: var(--glass-1);
  -webkit-backdrop-filter: blur(var(--blur-1)) saturate(150%);
  backdrop-filter: blur(var(--blur-1)) saturate(150%);
  border: 1px solid var(--outline);
  border-radius: var(--r-lg);
  padding: calc(var(--u) * 2.5);
  box-shadow: var(--shadow);
  animation: rise 420ms var(--ease) both;
}
/* inner light reflection on top-left edge */
.card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.14), transparent 42%);
  mask-image: linear-gradient(180deg, #000 0%, transparent 60%);
  -webkit-mask-image: linear-gradient(180deg, #000 0%, transparent 60%);
}
main > .card:nth-of-type(2) { animation-delay: 80ms; }
main > .card:nth-of-type(3) { animation-delay: 160ms; }
@keyframes rise {
  from { opacity: 0; transform: translate3d(0, 16px, 0); }
  to   { opacity: 1; transform: translate3d(0, 0, 0); }
}

/* fallback when backdrop-filter unsupported */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .card, .topbar { background: rgba(23, 31, 51, 0.94); }
}

.cardhead {
  display: flex;
  align-items: center;
  gap: calc(var(--u) * 1.25);
  margin-bottom: calc(var(--u) * 1.5);
}
.ico { width: 20px; height: 20px; color: var(--secondary); flex: none; }
h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.3;
  text-shadow: var(--txt-shadow);
}
.hint {
  margin: 0 0 calc(var(--u) * 2);
  font-size: 0.875rem;
  color: var(--on-variant);
  line-height: 1.55;
}

/* ── form ──────────────────────────────────────────────────────────── */
.field { display: block; margin-bottom: calc(var(--u) * 2); }
.field.tight { margin-bottom: 0; flex: 1; min-width: 0; }
.fieldlabel {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--on-variant);
  margin-bottom: calc(var(--u) * 0.75);
}

input, select, button { font: inherit; }

input[type="text"], input[type="password"], input[type="date"],
input[inputmode="numeric"], select {
  width: 100%;
  min-height: 48px;
  padding: 0 calc(var(--u) * 2.5);
  color: #fff;
  background: var(--glass-1);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid var(--outline);
  border-radius: var(--r-xl);
  transition: border-color 200ms var(--ease), background 200ms var(--ease);
  appearance: none;
}
input::placeholder { color: rgba(255, 255, 255, 0.42); }
input:hover, select:hover { background: var(--glass-2); }
input:focus, select:focus {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
  border-color: rgba(0, 128, 255, 0.55);
  background: var(--glass-2);
}
select {
  background-image: url("data:image/svg+xml;utf8,\
<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' \
stroke='%23adc9eb' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'>\
<path d='m4 6 4 4 4-4'/></svg>");
  background-repeat: no-repeat;
  background-position: right calc(var(--u) * 1.75) center;
  padding-right: calc(var(--u) * 5);
}
select option { background: var(--surface-low); color: var(--on-surface); }
input[type="date"] { color-scheme: dark; font-variant-numeric: tabular-nums; }

/* ── buttons ───────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: calc(var(--u) * 1);
  min-height: 48px;
  padding: 0 calc(var(--u) * 3);
  border-radius: var(--r-xl);
  border: 1px solid transparent;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 200ms var(--ease), transform 200ms var(--ease),
              box-shadow 200ms var(--ease), border-color 200ms var(--ease);
}
.btn.primary {
  background: #fff;
  color: #2f3131;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.24);
}
.btn.primary:hover { background: #e2e2e2; box-shadow: 0 6px 22px rgba(0, 0, 0, 0.3); }
.btn.primary:active { transform: translate3d(0, 1px, 0); box-shadow: 0 2px 10px rgba(0, 0, 0, 0.22); }
.btn.ghost {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  border-color: var(--outline);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.btn.ghost:hover { background: var(--glass-1); border-color: rgba(255, 255, 255, 0.32); }
.btn.ghost:active { transform: translate3d(0, 1px, 0); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }
.btn.wide { width: 100%; margin-top: calc(var(--u) * 1.5); }
form .btn { width: 100%; }

.row {
  display: flex;
  gap: calc(var(--u) * 1.5);
  margin-top: calc(var(--u) * 1.5);
  align-items: flex-end;
}
.row > .btn { flex: 1 1 0; min-width: 0; padding: 0 calc(var(--u) * 1.5); }

/* ── camera viewport ───────────────────────────────────────────────── */
.camera {
  position: relative;
  margin-top: calc(var(--u) * 1);
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: var(--r-lg);
  border: 1px dashed var(--outline);
  background: rgba(6, 14, 32, 0.42);
}
.camera::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.45);
}
video, img#preview {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  border-radius: var(--r-lg);
}
.cammsg {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: calc(var(--u) * 1.25);
  color: var(--on-variant);
  font-size: 0.875rem;
  text-align: center;
  padding: calc(var(--u) * 2.5);
}
.cammsg svg { width: 34px; height: 34px; opacity: 0.65; }

/* ── file picker ───────────────────────────────────────────────────── */
.filelabel {
  display: flex;
  align-items: center;
  gap: calc(var(--u) * 1.5);
  margin-top: calc(var(--u) * 1.5);
  padding: calc(var(--u) * 1.75) calc(var(--u) * 2);
  min-height: 48px;
  border: 1px solid var(--outline);
  border-radius: var(--r-xl);
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 200ms var(--ease), border-color 200ms var(--ease);
}
.filelabel:hover { background: var(--glass-1); border-color: rgba(255, 255, 255, 0.32); }
.filelabel svg { width: 18px; height: 18px; color: var(--secondary); flex: none; }
.filelabel input[type="file"] {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ── result banner ─────────────────────────────────────────────────── */
.result {
  margin: calc(var(--u) * 2) 0 0;
  padding: calc(var(--u) * 1.75) calc(var(--u) * 2);
  border-radius: var(--r-md);
  font-size: 0.875rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--glass-2);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid var(--outline);
  animation: rise 240ms var(--ease) both;
}
.result.ok  { border-color: rgba(32, 178, 170, 0.55); background: rgba(32, 178, 170, 0.14); color: #d3fbf7; }
.result.bad { border-color: rgba(255, 180, 171, 0.55); background: rgba(147, 0, 10, 0.28); color: #ffdad6; }

/* ── history list ──────────────────────────────────────────────────── */
.hist { list-style: none; margin: calc(var(--u) * 1.5) 0 0; padding: 0; }
.hist li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: calc(var(--u) * 1.5);
  padding: calc(var(--u) * 1.5) calc(var(--u) * 1.25);
  border-radius: var(--r-md);
  font-size: 0.875rem;
  border-bottom: 1px solid var(--outline-soft);
  transition: background 200ms var(--ease);
  animation: rise 300ms var(--ease) both;
}
.hist li:hover { background: var(--glass-1); }
.hist li:last-child { border-bottom: 0; }
.hist .t {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  color: #fff;
}
.hist .w {
  font-size: 0.75rem;
  color: var(--on-variant);
  text-align: right;
  max-width: 52%;
}
.hist li.hist-empty {
  justify-content: center;
  color: var(--on-variant);
  font-size: 0.8125rem;
  border-bottom: 0;
}

/* ── status pill ───────────────────────────────────────────────────── */
.pill {
  flex: none;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--on-variant);
  padding: calc(var(--u) * 0.625) calc(var(--u) * 1.5);
  border-radius: var(--r-full);
  border: 1px solid var(--outline);
  background: rgba(255, 255, 255, 0.06);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  white-space: nowrap;
}
.pill.ok  { color: #a7f3ed; border-color: rgba(32, 178, 170, 0.5); background: rgba(32, 178, 170, 0.16); }
.pill.bad { color: #ffdad6; border-color: rgba(255, 180, 171, 0.5); background: rgba(147, 0, 10, 0.26); }

.hidden { display: none !important; }

/* ── accessibility & motion ────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .orb { animation: none; }
}
@media (prefers-contrast: more) {
  :root { --outline: rgba(255, 255, 255, 0.4); --glass-1: rgba(255, 255, 255, 0.18); }
}

/* ── small phones ──────────────────────────────────────────────────── */
@media (max-width: 380px) {
  main { padding-left: calc(var(--u) * 2); padding-right: calc(var(--u) * 2); }
  .card { padding: calc(var(--u) * 2); }
  .row { flex-wrap: wrap; }
  .row > .btn { flex: 1 1 100%; }
}

/* ── dark-surface safety: iOS Safari date input ────────────────────── */
@supports (-webkit-touch-callout: none) {
  input[type="date"] { min-height: 46px; }
}
