/* DM Sans v1 (OFL): the Jush! brand typeface, Regular + Bold, subset to Latin + Latin Extended-A. */
@font-face {
  font-family: "DM Sans";
  src: url("/fonts/dm-sans-regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "DM Sans";
  src: url("/fonts/dm-sans-bold.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

/* Tokens: Jush! brand book (Księga znaku v0.8), primary palette on black. */
:root {
  --black: #000000;
  --white: #ffffff;
  --muted: rgba(255, 255, 255, 0.62);
  --faint: rgba(255, 255, 255, 0.5);
  --hairline: rgba(255, 255, 255, 0.18);
  --green: #8fcb01;       /* Jush light green */
  --green-hover: #a3de14;
  --green-dark: #006420;  /* Jush dark green */
  --error: #ff5022;       /* brand secondary orange */

  --font: "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --cell: 20px;
  --gutter: clamp(20px, 7vw, 112px);

  color-scheme: dark;
}

/* Both languages ship in the markup; show only the active one. */
:root[lang="pl"] span[lang="en"],
:root[lang="en"] span[lang="pl"] {
  display: none;
}

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

html {
  background: var(--black);
  color: var(--white);
  font-family: var(--font);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr;
  grid-template-columns: minmax(0, 1fr); /* never wider than the viewport */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button,
input {
  font: inherit;
  color: inherit;
}

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

/* ── Backdrop: a grid of terminal cells; drifting Jush-green glows light up the cells they pass. ── */

.backdrop,
.backdrop > * {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.backdrop {
  z-index: -1;
  overflow: hidden;
}

.cells {
  background-image: radial-gradient(circle, rgba(255, 255, 255, 0.1) 1px, transparent 1.5px);
  background-size: var(--cell) var(--cell);
  background-position: center;
}

.cells-lit {
  -webkit-mask-image: radial-gradient(circle, #000 2.3px, transparent 2.8px);
  mask-image: radial-gradient(circle, #000 2.3px, transparent 2.8px);
  -webkit-mask-size: var(--cell) var(--cell);
  mask-size: var(--cell) var(--cell);
  -webkit-mask-position: center;
  mask-position: center;
}

.aura,
.cells-lit {
  overflow: hidden;
}

.backdrop i {
  position: absolute;
  border-radius: 50%;
  will-change: transform;
}

/* Lit cells: bright lime at the core, fading through dark green. */
.cells-lit i {
  background: radial-gradient(closest-side, #8fcb01, rgba(143, 203, 1, 0.75) 32%, rgba(0, 100, 32, 0.6) 64%, rgba(0, 100, 32, 0));
}

/* A faint dark-green light under the same glows, so the page has depth between the dots. */
.aura i {
  background: radial-gradient(closest-side, rgba(0, 100, 32, 0.42), rgba(0, 100, 32, 0));
}

.backdrop i:nth-child(1) {
  top: -34vmax;
  left: 18vw;
  width: 70vmax;
  height: 70vmax;
  animation: drift-a 30s ease-in-out infinite alternate;
}

.backdrop i:nth-child(2) {
  bottom: -42vmax;
  right: -28vmax;
  width: 62vmax;
  height: 62vmax;
  animation: drift-b 38s ease-in-out infinite alternate;
}

.backdrop i:nth-child(3) {
  top: 38vh;
  left: -22vmax;
  width: 40vmax;
  height: 40vmax;
  animation: drift-c 24s ease-in-out infinite alternate;
}

@keyframes drift-a {
  50% { transform: translate3d(30vw, 34vh, 0); }
  to { transform: translate3d(-10vw, 54vh, 0); }
}

@keyframes drift-b {
  50% { transform: translate3d(-46vw, -20vh, 0); }
  to { transform: translate3d(-20vw, -50vh, 0); }
}

@keyframes drift-c {
  50% { transform: translate3d(55vw, -22vh, 0); }
  to { transform: translate3d(95vw, 18vh, 0); }
}

/* On success the lit cells flare for a moment. */
.cells-lit.is-bright {
  animation: flare 1.6s ease-out;
}

@keyframes flare {
  25% { filter: brightness(1.5) saturate(1.2); }
}

/* ── Layout ── */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(20px, env(safe-area-inset-top)) max(var(--gutter), env(safe-area-inset-right)) 0
    max(var(--gutter), env(safe-area-inset-left));
}

.logo {
  display: block;
  width: 68px;
  height: auto;
}

.lang-switch {
  display: flex;
  gap: 2px;
  margin-right: -8px;
}

.lang-switch button {
  border: 0;
  background: none;
  padding: 10px 8px;
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--faint);
  cursor: pointer;
  border-radius: 8px;
  text-decoration: underline 2px transparent;
  text-underline-offset: 7px;
  transition: color 0.15s, text-decoration-color 0.15s;
}

.lang-switch button:hover {
  color: var(--white);
}

.lang-switch button[aria-pressed="true"] {
  color: var(--white);
  text-decoration-color: var(--green);
}

main {
  align-self: center;
  width: 100%;
  max-width: calc(46rem + 2 * var(--gutter));
  padding: 24px max(var(--gutter), env(safe-area-inset-right)) max(14vh, env(safe-area-inset-bottom))
    max(var(--gutter), env(safe-area-inset-left));
}

h1 {
  margin: 0;
  max-width: 11ch;
  font-size: clamp(2.625rem, 1.4rem + 5.4vw, 6rem);
  font-weight: 700;
  line-height: 0.98;
  letter-spacing: -0.045em;
  text-wrap: balance;
}

.sub {
  margin: 0.7em 0 0;
  font-size: clamp(1.125rem, 1rem + 0.5vw, 1.375rem);
  font-weight: 400;
  color: var(--muted);
}

/* ── The prompt: chevron, input, button in one bar ── */

/* A dark clearing behind the field and its output line: whatever the glow does,
   the cells around the input stay dim, so the field and messages keep their contrast. */
.signup {
  position: relative;
  isolation: isolate;
  max-width: 34rem;
  margin-top: clamp(2rem, 6vh, 3.25rem);
}

.signup::before {
  content: "";
  position: absolute;
  inset: -20px;
  z-index: -1;
  border-radius: 36px;
  background: rgba(0, 0, 0, 0.88);
  box-shadow: 0 0 48px 40px rgba(0, 0, 0, 0.88);
  pointer-events: none;
}

.prompt {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 6px 6px 20px;
  background: var(--black);
  border: 1.5px solid var(--hairline);
  border-radius: 18px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.prompt:focus-within {
  border-color: var(--green);
  box-shadow: 0 0 0 4px rgba(143, 203, 1, 0.18);
}

.prompt[data-state="error"] {
  border-color: var(--error);
}

.prompt[data-state="error"]:focus-within {
  box-shadow: 0 0 0 4px rgba(255, 80, 34, 0.18);
}

.field {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: text;
}

.chevron {
  flex: none;
  width: 12px;
  height: 16px;
  fill: none;
  stroke: var(--green);
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.field input {
  flex: 1;
  min-width: 0;
  width: 100%;
  height: 48px;
  padding: 0;
  border: 0;
  outline: none;
  background: transparent;
  font-size: max(16px, 1.0625rem); /* ≥16px stops iOS from zooming in */
  caret-color: var(--green);
}

.field input::placeholder {
  color: var(--faint);
  opacity: 1;
}

.field input:-webkit-autofill,
.field input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 100px var(--black) inset;
  -webkit-text-fill-color: var(--white);
  caret-color: var(--green);
}

.field input:read-only {
  color: var(--muted);
}

.prompt button {
  position: relative;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 48px;
  padding: 0 20px;
  border: 0;
  border-radius: 12px;
  background: var(--green);
  color: var(--black);
  font-size: 1rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s, transform 0.1s;
}

.prompt button:hover {
  background: var(--green-hover);
}

.prompt button:active {
  transform: scale(0.97);
}

.prompt button:focus-visible,
.lang-switch button:focus-visible {
  outline: 2px solid var(--white);
  outline-offset: 2px;
}

.icon {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.enter {
  opacity: 0.6;
}

.label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.label-done,
.spinner {
  display: none;
}

/* Overlays keep the button's width, so the row doesn't jump between states. */
.label-done,
.spinner {
  position: absolute;
  inset: 0;
  place-items: center;
  font-weight: 700;
}

.label-done .icon {
  width: 22px;
  height: 22px;
  stroke-width: 2.4;
}

.prompt[data-state="sending"] button {
  cursor: progress;
}

.prompt[data-state="sending"] .label-idle,
.prompt[data-state="sending"] .enter {
  visibility: hidden;
}

.prompt[data-state="sending"] .spinner {
  display: grid;
}

.prompt[data-state="done"] {
  border-color: var(--green);
}

.prompt[data-state="done"] button {
  background: rgba(143, 203, 1, 0.12);
  color: var(--green);
  cursor: default;
  transform: none;
}

.prompt[data-state="done"] .label-idle,
.prompt[data-state="done"] .enter {
  visibility: hidden;
}

.prompt[data-state="done"] .label-done {
  display: grid;
}

/* Desktop gets a hint that Enter works; touch keyboards have their own send key. */
@media not all and (hover: hover) and (pointer: fine) {
  .enter {
    display: none;
  }
}

/* ── Output line under the prompt ── */

.status {
  min-height: 1.6em;
  margin: 14px 0 0;
  padding-left: 22px;
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--muted);
}

.status:empty {
  visibility: hidden;
}

.status[data-kind="success"] {
  color: var(--green);
}

.status[data-kind="error"] {
  color: var(--error);
}

.status[data-kind="success"]::before,
.status[data-kind="error"]::before {
  display: inline-block;
  width: 1em;
  height: 1em;
  margin: 0 0.4em 0 -1.4em;
  vertical-align: -0.12em;
  font-weight: 700;
  text-align: center;
  line-height: 1;
}

.status[data-kind="success"]::before {
  content: "";
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='m3 8.5 3.2 3L13 4.5' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='m3 8.5 3.2 3L13 4.5' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}

.status[data-kind="error"]::before {
  content: "!";
}

.status.is-printing {
  animation: print 0.42s steps(24, end);
}

@keyframes print {
  from { clip-path: inset(0 100% 0 0); }
  to { clip-path: inset(0 0 0 0); }
}

/* ── Small screens: button drops under the input ── */

@media (max-width: 30rem) {
  .logo {
    width: 58px;
  }

  .prompt {
    flex-wrap: wrap;
    padding: 6px;
  }

  .field {
    flex-basis: 100%;
    padding-left: 14px;
  }

  .prompt button {
    flex: 1 1 100%;
    height: 52px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .backdrop i:nth-child(n),
  .cells-lit.is-bright,
  .status.is-printing {
    animation: none;
  }

  .prompt,
  .prompt button {
    transition: none;
  }
}
