/* ============================================================
   Scanu — design system
   Strict black & white. Geometry, restraint, and the scan effect.
   ============================================================ */

:root {
  /* Monochrome ramp — no hues anywhere in the product. */
  --ink:        #0a0a0a;
  --ink-80:     #2e2e2e;
  --ink-60:     #5c5c5c;
  --ink-40:     #8f8f8f;
  --ink-20:     #c9c9c9;
  --line:       #e6e6e6;
  --line-soft:  #f0f0f0;
  --surface:    #f7f7f7;
  --paper:      #ffffff;

  --radius:     2px;
  --radius-lg:  4px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;
  --space-9: 96px;
  --space-10: 140px;

  --font: "Inter", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI",
          Roboto, Helvetica, Arial, sans-serif;
  --mono: "JetBrains Mono", "SFMono-Regular", ui-monospace, Consolas, "Liberation Mono", monospace;

  --ease:      cubic-bezier(0.22, 0.61, 0.36, 1);
  --ease-out:  cubic-bezier(0.16, 1, 0.3, 1);
  --dur:       .28s;

  --shell:     1180px;
  --nav-h:     78px;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
  }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.6;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.025em; line-height: 1.08; }
h1 { font-size: clamp(42px, 6.8vw, 84px); }
h2 { font-size: clamp(31px, 4.3vw, 50px); }
h3 { font-size: clamp(21px, 2.2vw, 26px); letter-spacing: -0.015em; }
p  { margin: 0; }
a  { color: inherit; text-decoration: none; }
img, svg { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }

::selection { background: var(--ink); color: var(--paper); }

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

/* ---------------------------------------------------------- layout */
.shell {
  width: 100%;
  max-width: var(--shell);
  margin-inline: auto;
  padding-inline: 24px;
}
@media (max-width: 640px) { .shell { padding-inline: 20px; } }

.stack   { display: flex; flex-direction: column; }
.row     { display: flex; align-items: center; }
.gap-1 { gap: var(--space-1) } .gap-2 { gap: var(--space-2) }
.gap-3 { gap: var(--space-3) } .gap-4 { gap: var(--space-4) }
.gap-5 { gap: var(--space-5) } .gap-6 { gap: var(--space-6) }
.grow    { flex: 1 1 auto; min-width: 0; }
.spacer  { margin-left: auto; }
.hidden  { display: none !important; }
.center  { text-align: center; }

/* ---------------------------------------------------------- type */
.eyebrow {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .28em;
  text-transform: uppercase;
  color: var(--ink-40);
}
.lead  { font-size: clamp(17px, 1.7vw, 21px); color: var(--ink-60); line-height: 1.65; }
.muted { color: var(--ink-60); }
.small { font-size: 14px; }
.mono  { font-family: var(--mono); font-size: 13px; letter-spacing: .04em; }
.num   { font-variant-numeric: tabular-nums; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ============================================================
   THE SCAN EFFECT
   Four corner brackets drawn from eight gradients on one
   pseudo-element, plus a sweeping detection line.
   `.scan` owns ::before and ::after on its element.
   ============================================================ */
.scan { position: relative; isolation: isolate; }

.scan::after {
  --bracket: 14px;
  --inset: -8px;
  --scan-color: var(--ink);
  content: "";
  position: absolute;
  inset: var(--inset);
  pointer-events: none;
  z-index: 2;
  background-image:
    linear-gradient(var(--scan-color), var(--scan-color)),
    linear-gradient(var(--scan-color), var(--scan-color)),
    linear-gradient(var(--scan-color), var(--scan-color)),
    linear-gradient(var(--scan-color), var(--scan-color)),
    linear-gradient(var(--scan-color), var(--scan-color)),
    linear-gradient(var(--scan-color), var(--scan-color)),
    linear-gradient(var(--scan-color), var(--scan-color)),
    linear-gradient(var(--scan-color), var(--scan-color));
  background-repeat: no-repeat;
  background-size:
    var(--bracket) 1.5px, 1.5px var(--bracket),
    var(--bracket) 1.5px, 1.5px var(--bracket),
    var(--bracket) 1.5px, 1.5px var(--bracket),
    var(--bracket) 1.5px, 1.5px var(--bracket);
  background-position:
    left top, left top,
    right top, right top,
    left bottom, left bottom,
    right bottom, right bottom;
  opacity: 0;
  transform: scale(1.035);
  transition: opacity .2s var(--ease), transform .45s var(--ease-out);
}

.scan:hover::after,
.scan:focus-visible::after,
.scan.is-scanning::after { opacity: 1; transform: scale(1); }

/* sweeping detection line */
.scan::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(
    to bottom,
    transparent 0%,
    rgba(10, 10, 10, .07) 45%,
    rgba(10, 10, 10, .16) 50%,
    rgba(10, 10, 10, .07) 55%,
    transparent 100%
  );
  background-size: 100% 220%;
  background-repeat: no-repeat;
  background-position: 0 -120%;
  transition: opacity .2s var(--ease);
}
.scan:hover::before,
.scan.is-scanning::before {
  opacity: 1;
  animation: scan-sweep 1.45s var(--ease) infinite;
}
@keyframes scan-sweep {
  0%   { background-position: 0 -120%; }
  70%  { background-position: 0 120%; }
  100% { background-position: 0 120%; }
}

/* Inverted surfaces flip the brackets and the sweep to white. */
.on-dark .scan::after,
.scan.on-dark::after { --scan-color: var(--paper); }
.on-dark .scan::before,
.scan.on-dark::before {
  background: linear-gradient(
    to bottom, transparent 0%,
    rgba(255, 255, 255, .06) 45%, rgba(255, 255, 255, .14) 50%,
    rgba(255, 255, 255, .06) 55%, transparent 100%);
  background-size: 100% 220%;
  background-repeat: no-repeat;
}

.scan--tight::after { --inset: -4px; --bracket: 10px; }
.scan--wide::after  { --inset: -14px; --bracket: 22px; }
.scan--flush::after { --inset: 6px; }
.scan--quiet::before { display: none; }

/* ---------------------------------------------------------- buttons */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 28px;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  /* The hover fill is a background LAYER, not an overlay pseudo-element:
     backgrounds always paint behind text, so the label can never be covered,
     and both ::before and ::after stay free for `.scan` to use. */
  background-color: var(--ink);
  background-image: linear-gradient(var(--paper), var(--paper));
  background-repeat: no-repeat;
  background-position: 50% 100%;
  background-size: 100% 0%;
  color: var(--paper);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: .01em;
  cursor: pointer;
  overflow: hidden;
  transition: background-size .34s var(--ease-out),
              background-color var(--dur) var(--ease),
              color var(--dur) var(--ease),
              border-color var(--dur) var(--ease),
              transform .18s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.btn > * { position: relative; z-index: 1; }
.btn:active { transform: translateY(1px); }
.btn:hover { background-size: 100% 100%; color: var(--ink); }

.btn--ghost {
  background-color: transparent;
  background-image: linear-gradient(var(--ink), var(--ink));
  color: var(--ink);
  border-color: var(--ink-20);
}
.btn--ghost:hover { color: var(--paper); border-color: var(--ink); }

.btn--quiet {
  background-color: transparent;
  background-image: none;
  color: var(--ink-60);
  border-color: transparent;
  padding-inline: 14px;
}
.btn--quiet:hover { color: var(--ink); background-color: var(--surface); }

.btn--invert {
  background-color: var(--paper);
  background-image: linear-gradient(var(--ink), var(--ink));
  color: var(--ink);
  border-color: var(--paper);
}
.btn--invert:hover { color: var(--paper); }

.btn--sm  { padding: 9px 18px; font-size: 14px; }
.btn--xs  { padding: 7px 13px; font-size: 13px; }
.btn--lg  { padding: 17px 36px; font-size: 16px; }
.btn--block { width: 100%; }
.btn--icon { padding: 9px; aspect-ratio: 1; }
.btn[disabled], .btn.is-loading { opacity: .45; pointer-events: none; }

.btn.is-loading::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 2px;
  background: currentColor;
  animation: btn-progress 1.1s var(--ease) infinite;
  z-index: 2;
}
@keyframes btn-progress {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.link-underline {
  position: relative;
  padding-bottom: 2px;
}
.link-underline::after {
  content: "";
  position: absolute;
  left: 0; bottom: 0;
  width: 100%; height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: right;
  transition: transform .35s var(--ease-out);
}
.link-underline:hover::after { transform: scaleX(1); transform-origin: left; }

/* ---------------------------------------------------------- forms */
.field { display: flex; flex-direction: column; gap: 7px; }
.field > label {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink-60);
}
.field .hint { font-size: 13px; color: var(--ink-40); }

.input, .select, .textarea {
  width: 100%;
  padding: 13px 15px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 16px;
  transition: border-color .2s var(--ease), background .2s var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--ink-20); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-20); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--ink);
}
.textarea { resize: vertical; min-height: 96px; line-height: 1.5; }
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' stroke='%230a0a0a' stroke-width='1.4' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 11px;
  padding-right: 38px;
  cursor: pointer;
}
.input[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--ink); background: var(--surface); }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 15px; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  width: 40px; height: 22px;
  border: 1px solid var(--ink-20);
  border-radius: 999px;
  position: relative;
  transition: background .25s var(--ease), border-color .25s var(--ease);
}
.switch .track::after {
  content: "";
  position: absolute;
  top: 50%; left: 3px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--ink-40);
  transform: translateY(-50%);
  transition: transform .28s var(--ease-out), background .25s var(--ease);
}
.switch input:checked + .track { background: var(--ink); border-color: var(--ink); }
.switch input:checked + .track::after { transform: translate(18px, -50%); background: var(--paper); }
.switch input:focus-visible + .track { outline: 2px solid var(--ink); outline-offset: 2px; }

/* ---------------------------------------------------------- pieces */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .16em;
  text-transform: uppercase;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 4px 9px;
  color: var(--ink-60);
  white-space: nowrap;
}
.tag--solid { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.tag--dot::before {
  content: "";
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--paper);
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease-out);
}
.card:hover { border-color: var(--ink-20); }

.divider { height: 1px; background: var(--line); border: 0; margin: 0; }

/* ---------------------------------------------------------- brand lockup
   The wordmark is the logo's own lettering, drawn as SVG strokes rather than
   set in a typeface, so it stays identical wherever the brand appears. Both
   halves inherit `currentColor`, so a dark surface needs no separate asset. */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  flex: 0 0 auto;        /* never let a crowded row shrink the lockup */
}
/* Both halves are sized from two custom properties, and the wordmark's width
   is COMPUTED from its height rather than inferred. `img, svg { max-width:
   100% }` above, or any flex squeeze, would otherwise narrow the box and make
   preserveAspectRatio scale the letters down inside it - which is exactly how
   a 46px wordmark ended up rendering at about 5px. Nothing here depends on
   intrinsic sizing, so there is no longer a width axis to get squeezed on.
   The wordmark viewBox is 366x56, hence the 6.5357 multiplier. */
.brand {
  --mark-size: 34px;
  --word-h: 34px;
}
.brand .brand-mark {
  width: var(--mark-size);
  height: var(--mark-size);
  min-width: var(--mark-size);
  max-width: none;
  flex: 0 0 auto;
}
.brand .brand-word {
  height: var(--word-h);
  width: calc(var(--word-h) * 6.5357);
  min-width: calc(var(--word-h) * 6.5357);
  max-width: none;
  flex: 0 0 auto;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  cursor: pointer;
  color: var(--ink-60);
  transition: color .2s var(--ease), border-color .2s var(--ease), background .2s var(--ease);
}
.icon-btn:hover { color: var(--ink); border-color: var(--ink); }
.icon-btn--danger:hover { background: var(--ink); color: var(--paper); }

/* ---------------------------------------------------------- toasts */
#toasts {
  position: fixed;
  right: 20px; bottom: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(380px, calc(100vw - 40px));
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 16px;
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--radius);
  font-size: 15px;
  line-height: 1.45;
  box-shadow: 0 18px 40px rgba(0, 0, 0, .22);
  animation: toast-in .4s var(--ease-out) both;
}
.toast--error { background: var(--paper); color: var(--ink); border: 1.5px solid var(--ink); }
.toast.is-out { animation: toast-out .3s var(--ease) forwards; }
.toast .bar {
  width: 2px;
  align-self: stretch;
  background: currentColor;
  opacity: .55;
  flex: 0 0 2px;
}
@keyframes toast-in  { from { opacity: 0; transform: translateY(14px) scale(.98); } }
@keyframes toast-out { to   { opacity: 0; transform: translateY(8px); } }

/* ---------------------------------------------------------- modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 10, .55);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 180;
  animation: fade-in .25s var(--ease) both;
}
.modal {
  width: min(560px, 100%);
  max-height: min(86vh, 720px);
  overflow: auto;
  background: var(--paper);
  border-radius: var(--radius-lg);
  animation: modal-in .38s var(--ease-out) both;
}
.modal header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 22px 24px;
  border-bottom: 1px solid var(--line);
}
.modal header h3 { flex: 1; }
.modal .body { padding: 24px; display: flex; flex-direction: column; gap: 18px; }
.modal footer { padding: 18px 24px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; }
@keyframes fade-in  { from { opacity: 0; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(18px) scale(.985); } }

/* ---------------------------------------------------------- states */
.empty-state {
  padding: 72px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-lg);
}
.empty-state svg { color: var(--ink-20); }

.skeleton {
  background: linear-gradient(90deg, var(--line-soft) 25%, var(--surface) 37%, var(--line-soft) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s linear infinite;
  border-radius: var(--radius);
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* ---------------------------------------------------------- reveal */
[data-reveal] {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity .75s var(--ease-out), transform .75s var(--ease-out);
  transition-delay: var(--reveal-delay, 0ms);
}
[data-reveal].is-visible { opacity: 1; transform: none; }

.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;
}

.skip-link {
  position: absolute;
  left: 16px; top: -60px;
  z-index: 300;
  background: var(--ink);
  color: var(--paper);
  padding: 10px 16px;
  border-radius: var(--radius);
  transition: top .2s var(--ease);
}
.skip-link:focus { top: 16px; }
