/* Aurora V1 visual language (PRD §11).
   Reference points are Apple / Arc / Linear / Raycast: restraint, generous
   space, one accent doing the work, motion slow enough that you notice it only
   if you look for it. */

:root {
  --radius-lg: 24px;
  --radius-md: 14px;
  --radius-sm: 10px;

  --blue: #5aa9ff;
  --purple: #8b7cff;
  --pink: #ff7ab8;
  --red: #ff6b6b;
  --green: #4ade80;
  --amber: #fbbf24;

  --ease: cubic-bezier(0.32, 0.72, 0, 1);

  color-scheme: dark light;
}

/* Dark is the default: glass and luminous gradients need something to glow
   against. Light is a genuine second design, not an inversion. */
:root,
:root[data-theme='dark'] {
  --canvas: #08080e;
  --fg: #f4f4f8;
  --fg-muted: rgba(244, 244, 248, 0.6);
  --fg-faint: rgba(244, 244, 248, 0.66);
  --glass: rgba(255, 255, 255, 0.055);
  --glass-strong: rgba(255, 255, 255, 0.09);
  --edge: rgba(255, 255, 255, 0.11);
  --edge-strong: rgba(255, 255, 255, 0.2);
  --shadow: 0 1px 1px rgba(0, 0, 0, 0.4), 0 16px 48px rgba(0, 0, 0, 0.45);
  --blob-opacity: 0.5;
  --track: rgba(255, 255, 255, 0.1);
}

@media (prefers-color-scheme: light) {
  :root {
    --canvas: #f7f7fb;
    --fg: #14141c;
    --fg-muted: rgba(20, 20, 28, 0.62);
    /* 0.4 alpha looked right but measured 2.55:1 - below AA for the 11-13px text
     this drives (labels, stat keys, hints). Hierarchy comes from size, weight
     and letter-spacing instead of from washing the colour out. */
  --fg-faint: rgba(20, 20, 28, 0.62);
    --glass: rgba(255, 255, 255, 0.66);
    --glass-strong: rgba(255, 255, 255, 0.82);
    --edge: rgba(20, 20, 28, 0.08);
    --edge-strong: rgba(20, 20, 28, 0.16);
    --shadow: 0 1px 1px rgba(20, 20, 40, 0.04), 0 16px 44px rgba(20, 20, 60, 0.1);
    --blob-opacity: 0.42;
    --track: rgba(20, 20, 28, 0.08);
  }
}

:root[data-theme='light'] {
  --canvas: #f7f7fb;
  --fg: #14141c;
  --fg-muted: rgba(20, 20, 28, 0.62);
  /* 0.4 alpha looked right but measured 2.55:1 - below AA for the 11-13px text
     this drives (labels, stat keys, hints). Hierarchy comes from size, weight
     and letter-spacing instead of from washing the colour out. */
  --fg-faint: rgba(20, 20, 28, 0.62);
  --glass: rgba(255, 255, 255, 0.66);
  --glass-strong: rgba(255, 255, 255, 0.82);
  --edge: rgba(20, 20, 28, 0.08);
  --edge-strong: rgba(20, 20, 28, 0.16);
  --shadow: 0 1px 1px rgba(20, 20, 40, 0.04), 0 16px 44px rgba(20, 20, 60, 0.1);
  --blob-opacity: 0.42;
  --track: rgba(20, 20, 28, 0.08);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Roboto, 'Helvetica Neue', sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* ------------------------------------------------------------- background */

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.blob {
  position: absolute;
  width: 60vmax;
  height: 60vmax;
  border-radius: 50%;
  filter: blur(90px);
  opacity: var(--blob-opacity);
  will-change: transform;
}

.blob-1 { background: radial-gradient(circle at 30% 30%, var(--blue), transparent 62%); top: -22vmax; left: -14vmax; animation: drift-1 74s var(--ease) infinite; }
.blob-2 { background: radial-gradient(circle at 60% 40%, var(--purple), transparent 62%); top: 6vmax; right: -22vmax; animation: drift-2 88s var(--ease) infinite; }
.blob-3 { background: radial-gradient(circle at 40% 60%, var(--pink), transparent 62%); bottom: -26vmax; left: 8vmax; animation: drift-3 96s var(--ease) infinite; }
/* "slight red accents" - smaller and dimmer than the rest, on purpose */
.blob-4 { background: radial-gradient(circle at 50% 50%, var(--red), transparent 58%); width: 32vmax; height: 32vmax; bottom: 4vmax; right: 4vmax; opacity: calc(var(--blob-opacity) * 0.5); animation: drift-4 68s var(--ease) infinite; }

@keyframes drift-1 { 0%, 100% { transform: translate3d(0,0,0) scale(1); } 50% { transform: translate3d(9vmax, 7vmax, 0) scale(1.12); } }
@keyframes drift-2 { 0%, 100% { transform: translate3d(0,0,0) scale(1.06); } 50% { transform: translate3d(-11vmax, 9vmax, 0) scale(1); } }
@keyframes drift-3 { 0%, 100% { transform: translate3d(0,0,0) scale(1); } 50% { transform: translate3d(12vmax, -8vmax, 0) scale(1.1); } }
@keyframes drift-4 { 0%, 100% { transform: translate3d(0,0,0) scale(1); } 50% { transform: translate3d(-7vmax, -6vmax, 0) scale(1.2); } }

/* ------------------------------------------------------------------ layout */

.stage {
  position: relative;
  z-index: 1;
  flex: 1;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 40px 20px 24px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.card {
  background: var(--glass);
  border: 1px solid var(--edge);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px) saturate(140%);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
  padding: 32px;
  animation: rise 0.5s var(--ease) both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px) scale(0.99); }
  to { opacity: 1; transform: none; }
}

[hidden] { display: none !important; }

/* -------------------------------------------------------------- typography */

h1 {
  margin: 0 0 8px;
  font-size: 30px;
  line-height: 1.15;
  font-weight: 650;
  letter-spacing: -0.022em;
}

h2 {
  margin: 0 0 6px;
  font-size: 19px;
  font-weight: 620;
  letter-spacing: -0.012em;
}

.lede { margin: 0 0 26px; color: var(--fg-muted); }
.muted { color: var(--fg-muted); }
.faint { color: var(--fg-faint); font-size: 13px; }
.center { text-align: center; }

/* ---------------------------------------------------------------- dropzone */

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 40px 24px;
  border: 1.5px dashed var(--edge-strong);
  border-radius: var(--radius-md);
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: border-color 0.25s var(--ease), background 0.25s var(--ease), transform 0.25s var(--ease);
}

.dropzone:hover, .dropzone:focus-visible { background: var(--glass-strong); border-color: var(--purple); }
.dropzone.dragging { background: var(--glass-strong); border-color: var(--purple); border-style: solid; transform: scale(1.015); }

.dropzone-icon {
  width: 56px;
  height: 56px;
  color: var(--purple);
  /* the "glowing icon" from §8.1 */
  filter: drop-shadow(0 0 18px color-mix(in srgb, var(--purple) 65%, transparent));
  animation: breathe 5.5s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% { transform: translateY(0); opacity: 0.92; }
  50% { transform: translateY(-4px); opacity: 1; }
}

.dropzone-title { font-weight: 600; font-size: 16px; }

/* ----------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font: inherit;
  font-weight: 560;
  cursor: pointer;
  transition: transform 0.15s var(--ease), background 0.2s var(--ease), opacity 0.2s var(--ease);
}

.btn:active { transform: scale(0.975); }
.btn:disabled { opacity: 0.45; cursor: default; transform: none; }

.btn-primary {
  background: linear-gradient(135deg, var(--purple), var(--blue));
  color: #fff;
  box-shadow: 0 6px 20px color-mix(in srgb, var(--purple) 35%, transparent);
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }

.btn-ghost { background: var(--glass-strong); border-color: var(--edge); color: var(--fg); }
.btn-ghost:hover:not(:disabled) { border-color: var(--edge-strong); }

.btn-block { width: 100%; }

.btn-danger { background: transparent; border-color: var(--edge); color: var(--red); }
.btn-danger:hover:not(:disabled) { background: color-mix(in srgb, var(--red) 12%, transparent); }

/* -------------------------------------------------------------- file list */

.files {
  margin: 0 0 22px;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 190px;
  overflow-y: auto;
}

.file {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  background: var(--glass-strong);
  border: 1px solid var(--edge);
  border-radius: var(--radius-sm);
}

.file-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size { color: var(--fg-muted); font-variant-numeric: tabular-nums; font-size: 13px; }

.summary {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 18px;
  font-variant-numeric: tabular-nums;
}
.summary-total { font-size: 26px; font-weight: 640; letter-spacing: -0.02em; }

/* ------------------------------------------------------------ share + code */

.field-label {
  display: block;
  margin-bottom: 7px;
  font-size: 12px;
  font-weight: 620;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--fg-faint);
}

.step { margin-bottom: 22px; }

.copyrow { display: flex; gap: 8px; align-items: stretch; }

.copyrow input {
  flex: 1;
  min-width: 0;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--edge);
  background: var(--glass-strong);
  color: var(--fg);
  font: inherit;
  font-size: 13px;
}

.copyrow input:focus-visible { outline: 2px solid var(--purple); outline-offset: 1px; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  flex: none;
  border-radius: var(--radius-sm);
  border: 1px solid var(--edge);
  background: var(--glass-strong);
  color: var(--fg);
  cursor: pointer;
  transition: border-color 0.2s var(--ease), color 0.2s var(--ease);
}
.icon-btn:hover { border-color: var(--edge-strong); }
.icon-btn .i-done, .icon-btn.copied .i-copy { display: none; }
.icon-btn.copied .i-done { display: block; }
.icon-btn.copied { color: var(--green); border-color: var(--green); }

/* The code is the second factor. It gets its own visual weight so it does not
   read as an afterthought that belongs in the same message as the link. */
.codebox {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-radius: var(--radius-md);
  border: 1px solid color-mix(in srgb, var(--purple) 40%, var(--edge));
  background: color-mix(in srgb, var(--purple) 9%, transparent);
}

.code-value {
  font-size: 30px;
  font-weight: 680;
  letter-spacing: 0.16em;
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'ss01';
}

.hint { margin: 8px 0 0; font-size: 13px; color: var(--fg-muted); }

/* ------------------------------------------------------------------- QR (FR15) */

.qr-step { text-align: center; }

/* Always dark-on-white with its own quiet zone. A theme-matched QR looks nicer
   and scans worse, which is the wrong trade for the one element whose entire
   job is to be read by a camera. */
.qr {
  display: inline-block;
  padding: 10px;
  background: #fff;
  border-radius: var(--radius-sm);
  border: 1px solid var(--edge);
  line-height: 0;
}
.qr svg { width: 148px; height: 148px; display: block; }

/* ------------------------------------------------------ transfer controls (FR9/FR12) */

.controls { display: flex; gap: 10px; }
.controls .btn { flex: 1; }

.paused .ring-fill { stroke: var(--amber); }

/* --------------------------------------------------------------- code entry */

.code-input {
  width: 100%;
  padding: 15px 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--edge);
  background: var(--glass-strong);
  color: var(--fg);
  font: inherit;
  font-size: 26px;
  font-weight: 640;
  letter-spacing: 0.16em;
  text-align: center;
  text-transform: uppercase;
}
.code-input::placeholder { color: var(--fg-faint); font-weight: 500; }
.code-input:focus-visible { outline: 2px solid var(--purple); outline-offset: 1px; border-color: transparent; }
.code-input.bad { border-color: var(--red); animation: shake 0.4s var(--ease); }

@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  30%, 70% { transform: translateX(4px); }
  50% { transform: translateX(-4px); }
}

.error-text { color: var(--red); font-size: 13px; margin: 10px 0 0; }

/* ------------------------------------------------------------ progress ring */

.ring-wrap { position: relative; width: 190px; height: 190px; margin: 4px auto 22px; }

.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 7; stroke-linecap: round; }
.ring-track { stroke: var(--track); }
.ring-fill {
  stroke: url(#ring-gradient);
  /* The one place motion really matters (§11) - this is what people watch. */
  transition: stroke-dashoffset 0.45s var(--ease);
}

.ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.ring-pct { font-size: 38px; font-weight: 660; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.ring-label { font-size: 12px; color: var(--fg-muted); text-transform: uppercase; letter-spacing: 0.08em; }

/* --------------------------------------------------------------- stat grid */

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--edge);
  border: 1px solid var(--edge);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 20px;
}

.stat { background: var(--glass-strong); padding: 13px 16px; }
.stat-key { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--fg-faint); }
.stat-val { font-size: 15px; font-weight: 570; font-variant-numeric: tabular-nums; margin-top: 2px; }

.quality { display: inline-flex; align-items: center; gap: 7px; }
.quality-bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 13px; }
.quality-bars i { width: 3px; border-radius: 1px; background: var(--track); transition: background 0.3s var(--ease); }
.quality-bars i:nth-child(1) { height: 5px; }
.quality-bars i:nth-child(2) { height: 9px; }
.quality-bars i:nth-child(3) { height: 13px; }
.quality[data-level='1'] .quality-bars i:nth-child(-n+1),
.quality[data-level='2'] .quality-bars i:nth-child(-n+2),
.quality[data-level='3'] .quality-bars i:nth-child(-n+3) { background: var(--green); }
.quality[data-level='1'] .quality-bars i:nth-child(-n+1) { background: var(--amber); }

/* ------------------------------------------------------------- end states */

.verdict { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; }

.verdict-icon {
  width: 62px; height: 62px;
  display: grid; place-items: center;
  border-radius: 50%;
}
.verdict-icon svg { width: 30px; height: 30px; }
.verdict.ok .verdict-icon { background: color-mix(in srgb, var(--green) 16%, transparent); color: var(--green); }
.verdict.bad .verdict-icon { background: color-mix(in srgb, var(--red) 16%, transparent); color: var(--red); }
.verdict.neutral .verdict-icon { background: var(--glass-strong); color: var(--fg-muted); }

/* --------------------------------------------------------------- dev log */

.devlog {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 560px;
  margin: 0 auto 28px;
  padding: 0 20px;
  font-size: 12px;
  color: var(--fg-faint);
}
.devlog summary { cursor: pointer; padding: 6px 0; user-select: none; }
.devlog pre {
  margin: 6px 0 0;
  max-height: 210px;
  overflow: auto;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--edge);
  background: var(--glass);
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  line-height: 1.45;
}

/* ------------------------------------------------------------ a11y + motion */

:focus-visible { outline: 2px solid var(--purple); outline-offset: 2px; }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

@media (max-width: 480px) {
  .stage { padding: 20px 14px; }
  .card { padding: 24px 20px; border-radius: 20px; }
  h1 { font-size: 25px; }
  .code-value { font-size: 25px; }
  .stats { grid-template-columns: 1fr; }
}
