/* app.css — the web app at app.krystal.rip. The desktop app's look and feel
 * (krystal-desktop src/css): the same palette, fonts, crystal face, KRYSTAL
 * wordmark and "Calm+" motion rules — motion answers something, lands, and
 * comes to rest; light is a source, never an outline (no shadow halos around
 * panels); a fine still grain over the dark. Reduced-motion fallback at the
 * bottom. */

/* The desktop's fonts, cut down to Latin + Croatian (scripts/check-text.mjs
 * keeps every string inside that set): Inter for everything you read,
 * JetBrains Mono for codes and numbers, Orbitron for the wordmark only. */
@font-face {
  font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("/fonts/Inter-subset.woff2") format("woff2");
}
@font-face {
  font-family: "JetBrains Mono"; font-style: normal; font-weight: 100 800; font-display: swap;
  src: url("/fonts/JetBrainsMono-subset.woff2") format("woff2");
}
@font-face {
  font-family: "Orbitron"; font-style: normal; font-weight: 900; font-display: swap;
  src: url("/fonts/Orbitron-Black-latin.woff2") format("woff2");
}

:root {
  --bg: #0a0f0b; --bg-deep: #050806; --bg-elev: #0e140f; --bg-card: #121a15; --bg-card-2: #16201a;
  --well: #060a07;
  --border: #1f2a23; --border-2: #2b3a30;
  --fg: #e6efe8; --fg-muted: #93a399; --fg-dim: #647069;
  --accent: #a8ecbf; --accent-2: #6cc78e; --accent-3: #8fe0aa; --danger: #e2685a;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --ease: cubic-bezier(.2, .9, .3, 1);
  --ease-out: cubic-bezier(.2, .8, .2, 1);          /* glides, slides, settles */
  --ease-spring: cubic-bezier(.2, .9, .3, 1.25);    /* tiny accents only (a digit landing) */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; min-height: 100%; background: var(--bg-deep); color: var(--fg);
  font: 16px/1.55 var(--sans); -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; }

/* The fine, still grain over everything: it breaks up the banding dark
   gradients show on most screens, and gives the dark a material. Never moves. */
body::after {
  content: ''; position: fixed; inset: 0; z-index: 90; pointer-events: none;
  opacity: .05; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 1 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

/* ------------------------------- screens ------------------------------- */

/* The screen fills the page; the language switch follows it, never on top of it. */
body { display: flex; flex-direction: column; min-height: 100dvh; }
.screen { flex: 1 0 auto; display: flex; flex-direction: column; }
.screen[hidden] { display: none; }
@keyframes screen-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.screen:not([hidden]) { animation: screen-in .3s var(--ease-out) both; }

h2 { font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--fg-muted); margin: 26px 4px 10px; }
.sub { color: var(--fg-muted); font-size: 14.5px; margin: 0 0 16px; text-align: center; }
.sub.left { text-align: left; margin: -2px 4px 12px; font-size: 13.5px; }

/* ---------------------- the logo: crystal face + KRYSTAL ---------------------- */

.logo { display: flex; align-items: center; gap: 14px; }
.logo-word { display: flex; flex-direction: column; gap: 6px; }
.logo-name {
  font-family: "Orbitron", var(--sans); font-weight: 900; font-size: 24px; letter-spacing: .18em; line-height: 1;
  color: var(--fg); text-shadow: 0 0 14px rgba(108, 199, 142, .35); cursor: default;
}
.logo-tag { font-family: var(--mono); font-size: 11px; letter-spacing: .06em; color: var(--accent-2); opacity: .85; }

/* The wordmark lights up letter by letter (each .ltr carries a staggered delay,
   motion.js): one wave when something lands (`boot`), and on hover. */
.logo-name .ltr { display: inline-block; }
.logo-name:hover .ltr { animation: ltr-glow 1.7s ease-in-out infinite; }
.logo.boot .logo-name .ltr { animation: ltr-glow 1.7s ease-in-out 1; }
@keyframes ltr-glow {
  0%, 100%, 40%, 80% { color: var(--fg); text-shadow: 0 0 14px rgba(108, 199, 142, .35); transform: translateY(0); }
  20%, 60% {
    color: var(--accent-3);
    text-shadow: 0 0 10px rgba(108, 199, 142, .95), 0 0 22px rgba(108, 199, 142, .55);
    transform: translateY(-2px);
  }
}

/* The face (mascot.js draws and moves it). */
.logo-mascot { position: relative; flex: none; width: 56px; height: 56px; cursor: pointer; user-select: none; }
.logo-mascot svg { position: relative; display: block; width: 100%; height: 100%; overflow: visible; }
/* The light behind it: an edgeless falloff from the face, not an outline. Its
   strength and colour come from the face's state, so at rest it is faint and still. */
.mascot-lamp {
  position: absolute; inset: -70%; border-radius: 50%; pointer-events: none; opacity: 0;
  background: radial-gradient(closest-side,
    rgba(var(--mascot-tint, 143, 224, 170), .20), rgba(var(--mascot-tint, 143, 224, 170), .06) 55%, transparent);
}

/* -------------------------------- sign in ------------------------------- */

/* Underground: near-black, light only where something is. A low, wide pool of
   green from below (the floor of the room), the corners fall away to black. */
#signin {
  overflow-x: clip;   /* the card's light spills past the edges; it mustn't make the page scroll */
  background:
    radial-gradient(ellipse 70% 45% at 50% 108%, rgba(108, 199, 142, .10), transparent 70%),
    radial-gradient(ellipse 120% 90% at 50% 40%, var(--bg) 30%, var(--bg-deep) 100%);
}

/* Phones: one column — what this is, the way in, then how it works.
   Wide screens: the pitch and the steps on the left, the card on the right. */
.welcome {
  width: 100%; max-width: 420px; margin: 0 auto; padding: calc(36px + var(--safe-top)) 20px 36px;
  display: grid; grid-template-areas: "pitch" "auth" "how"; align-content: start;
}
.pitch { grid-area: pitch; text-align: center; }
.hero-logo { justify-content: center; margin-bottom: 30px; }
.hero-logo .logo-mascot { width: 60px; height: 60px; }
.eyebrow { font: 500 11.5px/1 var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--accent-2); margin: 0 0 12px; }
.pitch-title { font-size: 30px; font-weight: 800; line-height: 1.12; letter-spacing: -.025em; margin: 0 0 12px; }
.pitch-sub { color: var(--fg-muted); font-size: 15px; margin: 0 0 30px; }

/* The card sits in its own light (light.js) — no drop shadow: a shadow starts
   at a crisp edge and the eye finds the box. */
.auth-wrap { grid-area: auth; position: relative; }
.auth-light { position: absolute; inset: -30% -40%; pointer-events: none; }
.auth-light i, .l-floor { position: absolute; display: block; pointer-events: none; border-radius: 50%; }
.auth-light::before {   /* the room: a very faint, still wash so the card is never in a void */
  content: ''; position: absolute; inset: -20%; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(108, 199, 142, .045), transparent);
}
.l-lamp, .l-red { inset: 0; opacity: 0; will-change: opacity; }
.l-lamp { background: radial-gradient(closest-side, rgba(108, 199, 142, .2), rgba(108, 199, 142, .065) 55%, transparent); }
.l-red { background: radial-gradient(closest-side, rgba(226, 104, 90, .2), rgba(226, 104, 90, .06) 55%, transparent); }
.l-beat {
  inset: 8% -10%; opacity: 0;
  background: radial-gradient(closest-side, rgba(143, 224, 170, .2), rgba(108, 199, 142, .05) 60%, transparent);
}
.l-beat.go { animation: light-beat 1.3s var(--ease-out); }
@keyframes light-beat { from { opacity: 1; transform: scale(.75); } to { opacity: 0; transform: scale(1.12); } }

.auth {
  position: relative; overflow: hidden; border-radius: 18px; padding: 18px 18px 20px;
  background: linear-gradient(180deg, rgba(18, 26, 21, .94), rgba(10, 15, 11, .96));
  border: 1px solid var(--border-2);
  box-shadow: inset 0 1px 0 rgba(143, 224, 170, .07);
}
.auth > :not(.l-floor) { position: relative; }
/* The floor of the card warms under your typing and cools when you stop. */
.l-floor {
  left: 50%; bottom: -150px; width: 130%; height: 260px; transform: translateX(-50%); opacity: 0;
  background: radial-gradient(closest-side, rgba(108, 199, 142, .2), rgba(108, 199, 142, .06) 55%, transparent);
}

.card-title { font-size: 20px; font-weight: 700; letter-spacing: -.01em; text-align: center; margin: 4px 0 6px; }
.hint { color: var(--fg-dim); font-size: 13px; text-align: center; margin: 14px 0 0; }

/* A step slides in from the side it lies on: forward from the right, back from
   the left (app.js sets --step-from). */
.auth .step:not([hidden]) { animation: step-in .28s var(--ease-out) both; }
.auth .step.again { animation-name: step-again; }
@keyframes step-in { from { opacity: 0; transform: translateX(var(--step-from, 0px)); } }
@keyframes step-again { from { opacity: 0; transform: translateX(var(--step-from, 0px)); } }

/* The two ways in. The mark glides under the chosen tab and stops there. */
.tabs { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; margin-bottom: 18px; background: var(--well); border: 1px solid var(--border); border-radius: 12px; }
.tabs[hidden] { display: none; }
.tabs-mark {
  position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc(50% - 4px);
  background: linear-gradient(180deg, #1b2a20, var(--bg-card-2)); border-radius: 8px;
  box-shadow: inset 0 1px 0 rgba(143, 224, 170, .08);
  transition: transform .32s var(--ease-out);
}
.tabs.join .tabs-mark { transform: translateX(100%); }
.tab { position: relative; padding: 9px 6px; border: 0; background: none; color: var(--fg-dim); font-size: 14.5px; font-weight: 600; cursor: pointer; }
.tab:hover { color: var(--fg-muted); }
.tab[aria-selected="true"] { color: var(--fg); }

.how { grid-area: how; list-style: none; margin: 40px 0 0; padding: 0 4px; display: grid; gap: 18px; }
.how li { display: flex; gap: 14px; align-items: baseline; }
.how-n { flex: none; font: 600 12px/1 var(--mono); color: var(--accent-2); letter-spacing: .04em; }
.how b { display: block; font-size: 15px; font-weight: 600; }
.how span:not(.how-n) { display: block; color: var(--fg-muted); font-size: 14px; }

@media (min-width: 880px) {
  .welcome {
    flex: 1; max-width: 980px; padding: 40px 32px;
    grid-template-columns: 1fr 380px; grid-template-areas: "pitch auth" "how auth";
    column-gap: 90px; align-content: center;
  }
  .pitch { text-align: left; align-self: end; }
  .hero-logo { justify-content: flex-start; }
  .pitch-title { font-size: 48px; }
  .pitch-sub { font-size: 16.5px; max-width: 460px; }
  .auth-wrap { align-self: center; }
  .auth { padding: 22px 24px 24px; }
  .how { margin-top: 12px; align-self: start; }
}

/* -------------------------------- fields -------------------------------- */

.field {
  width: 100%; padding: 14px 15px; border: 1px solid var(--border-2); border-radius: 12px;
  background: var(--well); color: var(--fg); font: inherit; outline: none;
  transition: border-color .18s var(--ease);
}
.field:focus { border-color: var(--accent-2); }
.field[readonly] { color: var(--fg-muted); }
.field.small { padding: 11px 13px; font-size: 15px; }

.btn {
  width: 100%; margin-top: 12px; padding: 14px; border: 1px solid var(--border-2); border-radius: 12px;
  background: var(--bg-card); font-weight: 600; cursor: pointer;
  transition: transform .12s ease, opacity .18s ease;
}
.btn.primary {
  background: linear-gradient(180deg, var(--accent-3), var(--accent-2)); border-color: var(--accent-2); color: #06210f;
}
.btn:not(:disabled):hover { transform: translateY(-1px); }
.btn.small { width: auto; margin: 0; padding: 10px 14px; font-size: 14px; white-space: nowrap; }
.btn:disabled { opacity: .55; cursor: default; }

/* The code: six cells drawn from one real input laid invisibly over them, so
   paste and the phone's one-time-code autofill work as usual. */
.cells { position: relative; display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.cells-input {
  position: absolute; inset: 0; z-index: 1; width: 100%; opacity: 0; border: 0; padding: 0;
  font-size: 16px; color: transparent; caret-color: transparent; background: none; cursor: text;
}
.cell {
  height: 58px; display: flex; align-items: center; justify-content: center;
  background: var(--well); border: 1px solid var(--border-2); border-radius: 10px;
  font: 600 26px/1 var(--mono); color: var(--fg);
  transition: border-color .18s ease, background .25s ease;
}
.cell.now { border-color: var(--accent-2); }
/* A digit lands in its cell: a tiny pop, the one springy accent here. */
.cell.pop { animation: cell-pop .26s var(--ease-spring); }
@keyframes cell-pop { from { transform: scale(.78); } }
.cells.bad .cell { border-color: rgba(226, 104, 90, .7); color: var(--danger); }
/* The right code: the row lights green, left to right, and stays lit as it goes. */
.cells.ok .cell { background: rgba(108, 199, 142, .2); border-color: var(--accent-2); color: var(--accent-3); }
.cells.ok .cell:nth-child(3) { transition-delay: .05s; } .cells.ok .cell:nth-child(4) { transition-delay: .1s; }
.cells.ok .cell:nth-child(5) { transition-delay: .15s; } .cells.ok .cell:nth-child(6) { transition-delay: .2s; }
.cells.ok .cell:nth-child(7) { transition-delay: .25s; }

/* What was wrong shakes once — local, at the thing itself. */
.shake { animation: shake .42s ease; }
@keyframes shake {
  20% { transform: translateX(-7px); } 40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); } 80% { transform: translateX(2px); }
}

.links { display: flex; justify-content: space-between; gap: 12px; margin-top: 14px; }
.link { background: none; border: 0; padding: 4px 0; color: var(--accent-3); font-size: 14px; cursor: pointer; }
.link.danger { color: var(--danger); }
.link:disabled { color: var(--fg-dim); cursor: default; font-variant-numeric: tabular-nums; }
.link.on { color: var(--fg); font-weight: 600; }

.err { color: var(--danger); font-size: 14px; text-align: center; margin: 16px 0 0; }
.err:not([hidden]) { animation: step-in .22s var(--ease-out) both; --step-from: 0px; }
.invite-note {
  background: rgba(108, 199, 142, .08); border: 1px solid rgba(108, 199, 142, .22); border-radius: 12px;
  padding: 12px 14px; margin: 0 0 14px; font-size: 14px; color: var(--accent);
}

/* ------------------------------- dashboard ------------------------------ */

.bar {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + var(--safe-top)) 16px 10px; background: rgba(5, 8, 6, .92);
}
.bar-logo { gap: 10px; }
.bar-logo .logo-mascot { width: 30px; height: 30px; }
.bar-logo .logo-name { font-size: 14px; }
.bar-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--bg-card-2);
  color: var(--accent-3); font-weight: 700; cursor: pointer;
}
.menu {
  position: absolute; right: 14px; top: calc(54px + var(--safe-top)); z-index: 3; min-width: 220px;
  background: var(--bg-card-2); border-radius: 12px; padding: 6px; box-shadow: 0 14px 40px rgba(0, 0, 0, .45);
  transform-origin: top right;
}
.menu:not([hidden]) { animation: menu-in .16s var(--ease) both; }
@keyframes menu-in { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
.menu-who { padding: 8px 10px; font-size: 13px; color: var(--fg-muted); overflow: hidden; text-overflow: ellipsis; }
.menu-item { display: block; width: 100%; text-align: left; padding: 10px; border: 0; border-radius: 8px; background: none; cursor: pointer; }
.menu-item:active { background: var(--bg-card); }

.scroll { width: 100%; max-width: 640px; margin: 0 auto; padding: 0 14px 40px; }

.empty { background: var(--bg-card); border-radius: 14px; padding: 22px 18px; text-align: center; }
.empty-ico { color: var(--fg-dim); margin-bottom: 8px; }
.empty-title { font-weight: 600; }
.empty-text { color: var(--fg-muted); font-size: 14px; margin-top: 4px; }

.inv-form { display: flex; gap: 8px; }
.inv-made { background: var(--bg-card-2); border-radius: 12px; padding: 12px 14px; margin-top: 10px; }
.inv-made:not([hidden]) { animation: screen-in .22s var(--ease) both; }
.inv-made-label { font-size: 13px; color: var(--fg-muted); }
.inv-link { display: block; margin: 8px 0 10px; font: 13px/1.4 var(--mono); color: var(--accent); word-break: break-all; user-select: all; }
.inv-made-actions { display: flex; gap: 8px; }
.list { margin-top: 12px; display: grid; gap: 6px; }
.inv-row { display: flex; align-items: center; gap: 10px; background: var(--bg-card); border-radius: 12px; padding: 11px 14px; }
.inv-text { flex: 1; min-width: 0; }
.inv-who { font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inv-state { font-size: 12.5px; color: var(--fg-dim); }

/* ------------------------------- chrome --------------------------------- */

.lang { padding: 8px 0 calc(16px + var(--safe-bottom)); text-align: center; font-size: 13px; color: var(--fg-dim); }
.lang .link { font-size: 13px; color: var(--fg-dim); }
.lang .link.on { color: var(--fg-muted); }

.toast {
  position: fixed; left: 50%; bottom: calc(52px + var(--safe-bottom)); transform: translateX(-50%);
  background: var(--bg-card-2); color: var(--fg); padding: 10px 16px; border-radius: 99px; font-size: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
}
.toast:not([hidden]) { animation: toast-in .2s var(--ease) both; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 6px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* Reduced motion keeps the information — which step, red or green, the light's
   level — and drops the movement. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .logo-name:hover .ltr { color: var(--accent-3); text-shadow: 0 0 16px rgba(108, 199, 142, .8); }
}
