/*
 * theme.css — 2FA Code Generator.
 *
 * Direction: a hardware security token on a desk. A cool sage-grey page,
 * plain white panels, buttons in a near-black green, and one dark LCD-style
 * screen where the code glows in lime — like an RSA SecurID or a YubiKey
 * OTP display, not a SaaS dashboard. In dark mode the lime moves onto the
 * buttons and the screen sinks to near-black.
 *
 * Type: Hanken Grotesk for words, Martian Mono for the code itself.
 * Own tokens (--x-*) paint the token screen in both modes.
 */

:root {
  --canvas: #eef0eb;
  --surface: #ffffff;
  --surface-2: #e4e8e1;
  --border: #d4d9d0;
  --border-strong: #a7aea2;
  --ink: #151a16;
  --muted: #545c53;
  --accent: #18241d;
  --accent-hover: #2a3a30;
  --accent-ink: #ffffff;
  --accent-text: #2c6a3b;
  --accent-strong: #2a5716;
  --accent-soft: #e2f1d1;
  --accent-border: #b8d99a;
  --success: #15803d;
  --success-ink: #ffffff;
  --success-soft: #dcefe2;
  --success-strong: #146c34;
  --warning: #b45309;
  --warning-ink: #ffffff;
  --warning-soft: #f6e8da;
  --warning-strong: #9a4706;
  --danger: #b91c1c;
  --danger-ink: #ffffff;
  --danger-soft: #f6e0df;
  --danger-strong: #a81b1b;
  --chart-1: #2c6a3b;
  --chart-2: #6b8f1f;
  --chart-3: #b45309;
  --chart-4: #0b5668;
  --chart-5: #7c285c;
  --chart-6: #5152a5;

  --x-screen: #0f1410;
  --x-screen-ink: #c8f36e;
  --x-screen-dim: #86997c;
  --x-screen-edge: #263027;
  --x-screen-warn: #ffb54a;
  --x-led: #4cc46a;

  --font-display: "Hanken Grotesk", ui-sans-serif, system-ui, sans-serif;
  --font-body: "Hanken Grotesk", ui-sans-serif, system-ui, sans-serif;
  --font-sans: "Hanken Grotesk", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "Martian Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --display-weight: 800;
  --display-tracking: -0.035em;
  --eyebrow-tracking: 0.08em;

  --radius-btn: 0.75rem;
  --radius-input: 0.75rem;
  --radius-card: 1.25rem;
  --border-w: 1px;
  --btn-weight: 600;
  --card-pad: 1.5rem;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.04), 0 12px 32px -18px rgba(0, 0, 0, 0.18);
  --shadow-raised: 0 2px 4px rgba(0, 0, 0, 0.05), 0 28px 60px -28px rgba(0, 0, 0, 0.35);
  --shadow-btn: 0 1px 0 rgba(255, 255, 255, 0.08) inset, 0 1px 2px rgba(0, 0, 0, 0.12);
}

html[data-theme="dark"] {
  --canvas: #0c0f0d;
  --surface: #151a16;
  --surface-2: #1d231e;
  --border: #283029;
  --border-strong: #444d45;
  --ink: #edf1ea;
  --muted: #9aa496;
  --accent: #c6f36b;
  --accent-hover: #d6f88e;
  --accent-ink: #10150e;
  --accent-text: #c6f36b;
  --accent-strong: #cfeea4;
  --accent-soft: #1f2b15;
  --accent-border: #3b5226;
  --success: #15803d;
  --success-ink: #ffffff;
  --success-soft: #12291a;
  --success-strong: #6cc68a;
  --warning: #b45309;
  --warning-ink: #ffffff;
  --warning-soft: #33240f;
  --warning-strong: #e3a457;
  --danger: #b91c1c;
  --danger-ink: #ffffff;
  --danger-soft: #3a1517;
  --danger-strong: #ec8a86;
  --chart-1: #c6f36b;
  --chart-2: #6cc68a;
  --chart-3: #e3a457;
  --chart-4: #1c9ec8;
  --chart-5: #cb70a4;
  --chart-6: #8f90e0;

  --x-screen: #050706;
  --x-screen-ink: #c8f36e;
  --x-screen-dim: #86997c;
  --x-screen-edge: #1c241d;
  --x-screen-warn: #ffb54a;
  --x-led: #c6f36b;
}

/*
 * app.css — what makes this app itself: the token screens.
 *
 * Every Auth Code sits on a dark LCD-style screen in glowing lime mono — the
 * big demo token on the sign-in page, the live preview in the add form, the
 * small screen on each saved login and on each key QR to secret finds. One
 * motion moment: the digits roll in when a new code arrives. Tokens only;
 * black is used purely as depth.
 */

/* ---- The page ground: a faint grid, like a cutting mat ---------------- */
.ground {
  background-color: var(--canvas);
  background-image:
    linear-gradient(color-mix(in srgb, var(--ink) 5%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--ink) 5%, transparent) 1px, transparent 1px);
  background-size: 2.5rem 2.5rem;
  background-position: -1px -1px;
}

/* ---- Sign-in card -------------------------------------------------------- */
.auth-card {
  padding: clamp(1.5rem, 4vw, 2.25rem);
  box-shadow: var(--shadow-raised);
}
.auth-card > * + * { margin-top: 1.5rem; }

.clock-chip {
  height: 1.75rem;
  padding: 0 0.625rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--muted);
  white-space: nowrap;
  cursor: help;
}

/* ---- Text fields that hold a key ------------------------------------------ */
.secret-field {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  letter-spacing: 0.03em;
  min-height: 4.75rem;
  word-break: break-all;
}

/* ---- Auth QR drop zone ------------------------------------------------------ */
.qr-drop {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-input, 0.75rem);
  background: var(--surface-2);
  transition: border-color 150ms ease, background-color 150ms ease, box-shadow 150ms ease;
}
.qr-drop:hover,
.qr-drop.is-over {
  border-color: var(--accent-text);
  background: var(--accent-soft);
}
.qr-drop:focus-within {
  border-color: var(--accent-text);
  box-shadow: var(--ring);
}
.qr-drop-inner {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  min-width: 0;
  padding: 0.75rem 1rem 0.75rem 0.75rem;
  cursor: pointer;
}
.qr-drop-inner > .min-w-0 > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qr-drop-icon {
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: var(--surface);
  color: var(--ink);
}
.qr-drop-icon .icon { width: 1.5rem; height: 1.5rem; }
.qr-thumb {
  width: 3rem;
  height: 3rem;
  flex-shrink: 0;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--surface);
}
.qr-status { font-size: 0.8125rem; color: var(--muted); }
.qr-status:empty { display: none; }
.qr-status.is-warn { color: var(--warning-strong); }
.qr-status.is-ok { color: var(--success-strong); }

/* ---- The big demo token (sign-in page) --------------------------------------- */
.token {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card, 1.25rem);
  box-shadow: var(--shadow-raised);
  padding: 0.75rem;
}
.token-head {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  min-width: 0;
  padding: 0.375rem 0.5rem 0.875rem;
  font-size: 0.8125rem;
  color: var(--muted);
}
.token-led {
  width: 0.5rem;
  height: 0.5rem;
  flex-shrink: 0;
  border-radius: 999px;
  background: var(--border-strong);
  transition: background-color 300ms ease, box-shadow 300ms ease;
}
.token.is-live .token-led {
  background: var(--x-led);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--x-led) 22%, transparent);
}
.token-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
  color: var(--ink);
}
.token-clock {
  margin-left: auto;
  flex-shrink: 0;
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  cursor: help;
}
.token-screen {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 14rem;
  padding: 2rem 1.5rem;
  border-radius: calc(var(--radius-card, 1.25rem) - 0.5rem);
  background:
    radial-gradient(120% 90% at 50% 0%, color-mix(in srgb, var(--x-screen-ink) 7%, transparent), transparent 60%),
    var(--x-screen);
  color: var(--x-screen-ink);
  box-shadow: inset 0 2px 12px rgba(0, 0, 0, 0.55), inset 0 0 0 1px var(--x-screen-edge);
  overflow: hidden;
}
.token-code {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: clamp(2.5rem, 6vw, 4.25rem);
  line-height: 1;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.token-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  margin-top: 1.75rem;
  font-size: 0.875rem;
  color: var(--x-screen-dim);
}
.token-seconds { white-space: nowrap; }
.token-seconds strong { font-family: var(--font-mono); font-weight: 600; color: var(--x-screen-ink); }
.token-next { margin-left: auto; white-space: nowrap; font-family: var(--font-mono); font-size: 0.75rem; }

/* ---- Codes on any screen -------------------------------------------------------- */
[data-code] {
  font-variant-numeric: tabular-nums;
  color: var(--x-screen-ink);
  text-shadow: 0 0 20px color-mix(in srgb, var(--x-screen-ink) 35%, transparent);
  transition: color 300ms ease, text-shadow 300ms ease;
}
.is-expiring [data-code],
.is-expiring [data-secs] {
  color: var(--x-screen-warn);
  text-shadow: 0 0 20px color-mix(in srgb, var(--x-screen-warn) 30%, transparent);
}

/* Countdown ring. */
.ring { width: 2.25rem; height: 2.25rem; flex-shrink: 0; transform: rotate(-90deg); }
.ring-sm { width: 1.25rem; height: 1.25rem; }
.ring-track { fill: none; stroke: var(--x-screen-edge); stroke-width: 4; }
.ring-sm .ring-track, .ring-sm .ring-bar { stroke-width: 6; }
.ring-bar {
  fill: none;
  stroke: var(--x-screen-ink);
  stroke-width: 4;
  stroke-linecap: round;
  transition: stroke-dashoffset 250ms linear, stroke 300ms ease;
}
.is-expiring .ring-bar { stroke: var(--x-screen-warn); }

/* ---- Live preview in the add form ------------------------------------------------ */
.preview-screen {
  padding: 0.875rem 1rem 1rem;
  border-radius: var(--radius-input, 0.75rem);
  background:
    radial-gradient(120% 120% at 50% 0%, color-mix(in srgb, var(--x-screen-ink) 7%, transparent), transparent 60%),
    var(--x-screen);
  color: var(--x-screen-ink);
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.5), inset 0 0 0 1px var(--x-screen-edge);
}
.preview-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--x-screen-dim);
}
.preview-secs {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-family: var(--font-mono);
  letter-spacing: 0;
  text-transform: none;
}
.preview-code {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  margin-top: 0.5rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.preview-code [data-code] {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: clamp(1.875rem, 7vw, 2.5rem);
  line-height: 1.1;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.preview-for {
  margin-top: 0.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.75rem;
  color: var(--x-screen-dim);
}
.preview-code:focus-visible { outline: 2px solid var(--x-screen-ink); outline-offset: 4px; border-radius: 0.375rem; }

/* ---- Saved logins ------------------------------------------------------------------ */
.login-list { display: flex; flex-direction: column; gap: 0.625rem; }

.login-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "who del" "code code";
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 0.875rem 0.875rem 1.125rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-card, 1.25rem);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}
@media (min-width: 40rem) {
  .login-row {
    grid-template-columns: minmax(0, 1fr) auto auto;
    grid-template-areas: "who code del";
  }
}
.login-row.is-fresh {
  border-color: var(--accent-border);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-border) 45%, transparent), var(--shadow-card);
}
.login-who { grid-area: who; min-width: 0; }
.login-email {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
  color: var(--ink);
}
.login-meta {
  margin-top: 0.125rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.8125rem;
  color: var(--muted);
}
.login-del { grid-area: del; }

/* The small screen on each row — the whole screen is the copy button. */
.lcd {
  grid-area: code;
  display: flex;
  align-items: center;
  gap: 0.625rem;
  min-width: 0;
  padding: 0.5rem 0.75rem 0.5rem 0.625rem;
  border: 0;
  border-radius: 0.875rem;
  background: var(--x-screen);
  color: var(--x-screen-ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  box-shadow: inset 0 1px 6px rgba(0, 0, 0, 0.5), inset 0 0 0 1px var(--x-screen-edge);
  transition: box-shadow 150ms ease;
}
@media (min-width: 40rem) { .lcd { justify-self: end; } }
.lcd:hover { box-shadow: inset 0 1px 6px rgba(0, 0, 0, 0.5), inset 0 0 0 1px color-mix(in srgb, var(--x-screen-ink) 40%, transparent); }
.lcd:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }
.lcd-code {
  flex: 1;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 1.375rem;
  line-height: 1.15;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.lcd-secs {
  min-width: 1.75rem;
  text-align: right;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--x-screen-dim);
}
.lcd-icon { display: grid; place-items: center; color: var(--x-screen-dim); transition: color 150ms ease; }
.lcd:hover .lcd-icon,
.lcd.is-done .lcd-icon,
.preview-code:hover .lcd-icon,
.preview-code.is-done .lcd-icon { color: var(--x-screen-ink); }

.filter-empty {
  margin-top: 1rem;
  padding: 1.5rem;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-card, 1.25rem);
  text-align: center;
  color: var(--muted);
}

/* ---- QR to secret: one card per key found ------------------------------------------ */
.extract-list { display: flex; flex-direction: column; gap: 0.75rem; }
.extract-card {
  padding: 1rem 1rem 1rem 1.125rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-card, 1.25rem);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}
.extract-card > * + * { margin-top: 0.875rem; }
.extract-top { display: flex; flex-direction: column; gap: 0.75rem; }
@media (min-width: 40rem) {
  .extract-top { flex-direction: row; align-items: center; justify-content: space-between; }
}
.extract-key {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0.75rem 0.75rem 1rem;
  border-radius: var(--radius-input, 0.75rem);
  background: var(--surface-2);
}
.extract-key > .min-w-0 { flex: 1; }
.extract-label {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.extract-secret {
  margin-top: 0.25rem;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  letter-spacing: 0.04em;
  color: var(--ink);
  word-break: break-all;
}
.extract-settings { font-size: 0.8125rem; color: var(--muted); }
.extract-actions { display: flex; flex-direction: column; gap: 0.5rem; }
@media (min-width: 30rem) {
  .extract-actions { flex-direction: row; align-items: center; justify-content: flex-end; }
}

/* ---- The one moment that moves: a new code rolls in ------------------------------ */
@keyframes code-roll {
  from { transform: translateY(0.35em); filter: blur(3px); }
  to   { transform: none; filter: none; }
}
[data-code].is-new { display: inline-block; animation: code-roll 420ms cubic-bezier(0.2, 0.8, 0.2, 1) both; }
html.reduced-motion [data-code].is-new { animation: none; }
html.reduced-motion .ring-bar { transition: none; }
