/* Dialboard sign-up and log-in.
   One calm card in front of an office wall, with the whiteboard softly out of focus behind it.
   Wall tokens change with the colour scheme; the card, ink and fields stay the same. */

@font-face {
  font-family: "Permanent Marker";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(../fonts/permanent-marker-latin.woff2) format("woff2");
}
@font-face {
  font-family: "Gochi Hand";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(../fonts/gochi-hand-latin.woff2) format("woff2");
}

:root {
  /* wall (redefined for dark mode) */
  --wall-1: #ddd6cb;
  --wall-2: #c3baad;
  --wall-glow: rgba(255, 250, 240, .55);
  --wall-shade: rgba(0, 0, 0, .16);
  --wall-shadow: rgba(48, 36, 22, .38);
  --wall-haze: rgba(226, 219, 208, .2);
  --wall-ink: #2b2826;
  --wall-ink-2: #4a443e;
  --wall-texture: .5;

  /* board materials (match the app) */
  --board-1: #fcfdfd;
  --board-2: #eef1f2;
  --frame-1: #f5f7f9;
  --frame-2: #cfd4da;
  --frame-3: #9ba2aa;
  --frame-4: #7b828a;
  --plastic: #4f555c;

  /* the card */
  --card: #fffefb;
  --card-edge: rgba(43, 40, 38, .09);
  --text: #2b2826;
  --text-2: #645d55;
  --text-3: #8b8379;
  --line: #958c80;       /* 3.3:1 on the card, WCAG 1.4.11 */
  --line-hover: #6f675c;
  --field: #ffffff;
  --autofill: #f2f5fd;

  /* ink */
  --ink-black: #2b2826;
  --ink-blue: #1b46c2;
  --ink-red: #d8382a;
  --ink-green: #0d7a4c;
  --ring: rgba(27, 70, 194, .26);
  --ring-red: rgba(216, 56, 42, .2);

  /* type */
  --font-marker: "Permanent Marker", "Marker Felt", "Chalkboard SE", "Comic Sans MS", cursive;
  --font-hand: "Gochi Hand", "Marker Felt", "Bradley Hand", "Comic Sans MS", cursive;
  --font-ui: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  /* layout */
  --gutter-l: max(16px, env(safe-area-inset-left, 0px));
  --gutter-r: max(16px, env(safe-area-inset-right, 0px));
  --kb: 0px; /* on-screen keyboard overlap, set by auth.js */
  --ease: cubic-bezier(.2, .8, .2, 1);

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --wall-1: #3a332d;
    --wall-2: #1f1b18;
    --wall-glow: rgba(255, 238, 210, .10);
    --wall-shade: rgba(0, 0, 0, .35);
    --wall-shadow: rgba(0, 0, 0, .72);
    --wall-haze: rgba(20, 17, 15, .75);
    --wall-ink: #efe9df;
    --wall-ink-2: #c9c1b5;
    --wall-texture: .28;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --wall-1: #3a332d;
  --wall-2: #1f1b18;
  --wall-glow: rgba(255, 238, 210, .10);
  --wall-shade: rgba(0, 0, 0, .35);
  --wall-shadow: rgba(0, 0, 0, .72);
  --wall-haze: rgba(20, 17, 15, .75);
  --wall-ink: #efe9df;
  --wall-ink-2: #c9c1b5;
  --wall-texture: .28;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

.vh {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Until auth.js has picked the mode from the URL, show only the card itself: no wrong form,
   nothing to type into. If the script never arrives, the form shows after a few seconds. */
html:not(.auth-ready) .card > :not(.magnet) {
  visibility: hidden;
  animation: auth-reveal 0s 10s forwards;
}
@keyframes auth-reveal { to { visibility: visible; } }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--wall-2);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  overflow-x: clip;
  background: var(--wall-2);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}

button, input { font: inherit; color: inherit; }
p { margin: 0; }

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

/* ------------------------------------------------------------------ the wall + board */

.wall {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background:
    radial-gradient(120% 90% at 18% -10%, var(--wall-glow), transparent 62%),
    radial-gradient(90% 70% at 100% 110%, var(--wall-shade), transparent 60%),
    linear-gradient(165deg, var(--wall-1), var(--wall-2));
}
.wall::before { /* matte paint */
  content: "";
  position: absolute;
  inset: 0;
  opacity: var(--wall-texture);
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .42 0 0 0 0 .37 0 0 0 0 .3 0 0 0 .16 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.wallboard {
  position: absolute;
  left: -14px;
  right: -14px;
  top: 70px;
  bottom: -60px;
  filter: blur(4px);
  transform: translateZ(0);
}
.wb-frame {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  background: linear-gradient(180deg, var(--frame-1) 0%, var(--frame-2) 22%, var(--frame-3) 78%, var(--frame-4) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .85),
    inset 0 -1px 0 rgba(0, 0, 0, .3),
    0 34px 60px -24px var(--wall-shadow),
    0 10px 18px -8px var(--wall-shadow);
}
.wb-corner {
  position: absolute;
  top: -2px;
  width: 26px;
  height: 26px;
  background: linear-gradient(145deg, #6b7178, var(--plastic) 55%, #33373c);
}
.wb-tl { left: -2px; border-radius: 12px 4px 10px 4px; }
.wb-tr { right: -2px; border-radius: 4px 12px 4px 10px; }
.wb-surface {
  position: absolute;
  inset: 12px;
  overflow: hidden;
  border-radius: 3px;
  background:
    radial-gradient(130% 85% at 12% -5%, rgba(255, 255, 255, .95), transparent 58%),
    radial-gradient(80% 60% at 92% 108%, rgba(160, 170, 178, .16), transparent 70%),
    linear-gradient(178deg, var(--board-1), var(--board-2));
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .2), inset 0 2px 5px rgba(0, 0, 0, .2);
}
.wb-ink {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover; /* auth.js draws at the surface's own size; this only covers a resize */
  object-position: 0 0;
  opacity: .82;
}
.wb-tray {
  position: absolute;
  left: 3%;
  right: 3%;
  bottom: -16px;
  height: 18px;
  border-radius: 2px 2px 9px 9px;
  background: linear-gradient(180deg, #e6e9ec, #a9afb6 55%, #7e858d);
  box-shadow: 0 10px 16px -8px var(--wall-shadow);
}
.wb-pen {
  position: absolute;
  top: -7px;
  width: 120px;
  height: 11px;
  border-radius: 6px 3px 3px 6px;
  background: linear-gradient(180deg, #fff, #e5e7ea);
}
.wb-pen::before {
  content: "";
  position: absolute;
  right: -2px;
  top: -1px;
  width: 38px;
  height: 13px;
  border-radius: 3px 6px 6px 3px;
  background: var(--cap);
}
.wb-pen-blue { left: 18%; --cap: var(--ink-blue); }
.wb-pen-red { left: calc(18% + 150px); --cap: var(--ink-red); }
.wb-eraser {
  position: absolute;
  top: -14px;
  right: 16%;
  width: 96px;
  height: 18px;
  border-radius: 4px;
  background: linear-gradient(180deg, #4b5056, #2f3337);
}
.wall-haze { position: absolute; inset: 0; background: var(--wall-haze); }

@media (max-width: 719px) {
  .wb-corner { display: none; }
  .wallboard { /* gone by the footer, which then sits on the plain wall */
    -webkit-mask-image: linear-gradient(180deg, #000 calc(100% - 330px), transparent calc(100% - 135px));
    mask-image: linear-gradient(180deg, #000 calc(100% - 330px), transparent calc(100% - 135px));
  }
}
@media (min-width: 720px) {
  .wallboard {
    left: 5vw;
    right: 5vw;
    top: max(88px, 11vh);
    bottom: max(84px, 11vh);
    filter: blur(5px);
  }
}

/* ------------------------------------------------------------------ header + footer (on the wall) */

.top {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  min-height: 64px;
  padding: max(10px, env(safe-area-inset-top, 0px)) var(--gutter-r) 0 var(--gutter-l);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-left: -8px;
  padding: 6px 10px 6px 8px;
  border-radius: 12px;
  color: var(--wall-ink);
  text-decoration: none;
  font-family: var(--font-marker);
  font-size: 23px;
  line-height: 1;
  letter-spacing: .01em;
}
.brand:focus-visible { outline-color: var(--wall-ink); }
.brand-mark {
  position: relative;
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(180deg, var(--frame-1), var(--frame-3));
  box-shadow: 0 1px 2px rgba(0, 0, 0, .25), 0 4px 10px -4px var(--wall-shadow);
}
.brand-mark::before { /* board surface inside the aluminium rim */
  content: "";
  position: absolute;
  inset: 2.5px;
  border-radius: 7px;
  background: linear-gradient(160deg, #fff, #eaeef0);
}
.brand-svg, .brand-ink {
  position: absolute;
  inset: 1px;
  width: 32px;
  height: 32px;
}
.brand-ink { visibility: hidden; }
.ink-ready .brand-ink { visibility: visible; }
.ink-ready .brand-svg { visibility: hidden; }

.foot {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 2px 18px;
  padding: 10px var(--gutter-r) max(18px, env(safe-area-inset-bottom, 0px)) var(--gutter-l);
  color: var(--wall-ink-2);
  font-size: 14px;
  text-align: center;
}
.foot a {
  padding: 8px 2px;
  border-radius: 6px;
  color: var(--wall-ink);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
.foot a:hover { text-decoration-thickness: 2px; }
.foot a:focus-visible { outline-color: var(--wall-ink); }

/* ------------------------------------------------------------------ stage + card */

.stage {
  position: relative;
  z-index: 1;
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 18px var(--gutter-r) calc(20px + var(--kb)) var(--gutter-l);
}

.card {
  position: relative;
  width: 100%;
  max-width: 440px;
  margin: clamp(32px, 10vh, 120px) 0 auto;
  padding: 40px 40px 30px;
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .9), rgba(255, 255, 255, 0) 120px),
    var(--card);
  box-shadow:
    0 0 0 1px var(--card-edge),
    0 1px 2px rgba(30, 20, 10, .08),
    0 22px 44px -18px var(--wall-shadow),
    0 60px 100px -50px var(--wall-shadow);
  color: var(--text);
  color-scheme: light; /* native controls stay light on the white card */
}

.magnet {
  position: absolute;
  top: -11px;
  left: 50%;
  width: 24px;
  height: 24px;
  margin-left: -12px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 28%, rgba(255, 255, 255, .8) 0 8%, rgba(255, 255, 255, 0) 18%),
    radial-gradient(circle at 50% 45%, var(--ink-red) 0 56%, #8f2318 100%);
  box-shadow:
    0 4px 5px -1px rgba(0, 0, 0, .32),
    0 1px 1px rgba(0, 0, 0, .22),
    inset 0 -3px 4px rgba(0, 0, 0, .2),
    inset 0 2px 2px rgba(255, 255, 255, .25);
}

.card-head { position: relative; }

.back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 40px;
  margin: -12px 0 6px -12px;
  padding: 0 12px 0 6px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--text-2);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}
.back svg { width: 20px; height: 20px; }
.back:hover { color: var(--text); background: rgba(43, 40, 38, .05); }

.eyebrow {
  margin-bottom: 2px;
  color: var(--ink-blue);
  font-family: var(--font-hand);
  font-size: 19px;
  line-height: 1.2;
}
.eyebrow:empty { display: none; }

.title-wrap { position: relative; padding-bottom: 12px; }
.title {
  margin: 0;
  color: var(--text);
  font-family: var(--font-marker);
  font-weight: 400;
  font-size: clamp(27px, 7.4vw, 34px);
  line-height: 1.14;
  letter-spacing: .005em;
  text-wrap: balance;
}
.title-line {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.sub {
  margin-top: 8px;
  color: var(--text-2);
  font-size: 16px;
  line-height: 1.45;
  text-wrap: pretty;
}

/* form-level message: empty and out of the way until there's something to say */
.notice:not(:empty) {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 10px;
  margin-top: 22px;
  padding: 12px 14px 12px 15px;
  border-radius: 12px;
  background: #fbf1ec;
  box-shadow: inset 3px 0 0 var(--ink-red);
  color: #9f2a1e;
  font-size: 15px;
  line-height: 1.4;
}
.notice .link { color: var(--ink-blue); }
.notice-msg { flex: 1 0 100%; }
.notice-email { min-width: 0; color: var(--text); font-weight: 600; overflow-wrap: anywhere; }

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

.form { margin-top: 26px; }
.field + .field { margin-top: 18px; }

.field label {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 7px;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .005em;
}
.optional { color: var(--text-2); font-weight: 400; }

.input {
  display: block;
  width: 100%;
  height: 50px;
  margin: 0;
  padding: 0 15px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--field);
  color: var(--text);
  font-size: 17px; /* >= 16px so iOS never zooms */
  line-height: 1.2;
  outline: none;
  box-shadow: 0 1px 0 rgba(43, 40, 38, .03);
  -webkit-appearance: none;
  appearance: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input::placeholder { color: var(--text-3); opacity: 1; }
.input:hover { border-color: var(--line-hover); }
.input:focus { border-color: var(--ink-blue); box-shadow: 0 0 0 4px var(--ring); }
.input[aria-invalid="true"] { border-color: var(--ink-red); }
.input[aria-invalid="true"]:focus { box-shadow: 0 0 0 4px var(--ring-red); }
.input:-webkit-autofill,
.input:-webkit-autofill:hover {
  -webkit-text-fill-color: var(--text);
  box-shadow: 0 0 0 100px var(--autofill) inset;
  caret-color: var(--text);
}
.input:-webkit-autofill:focus { box-shadow: 0 0 0 100px var(--autofill) inset, 0 0 0 4px var(--ring); }
.input::-webkit-calendar-picker-indicator { opacity: 0; } /* datalist arrow */

.pw { position: relative; }
.pw .input { padding-right: 78px; }
.pw .input::-ms-reveal,
.pw .input::-ms-clear { display: none; }
.pw-toggle {
  position: absolute;
  top: 6px;
  right: 6px;
  min-width: 62px;
  height: 38px;
  padding: 0 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--ink-blue);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}
.pw-toggle:hover { background: rgba(27, 70, 194, .08); }

.hint, .field-err, .tip, .caps { font-size: 14px; line-height: 1.35; }
.hint {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 7px;
  color: var(--text-2);
  transition: color .2s ease;
}
.hint-check { width: 16px; height: 16px; flex: none; display: none; }
.hint.ok { color: var(--ink-green); }
.hint.ok .hint-check { display: block; }
.field-err { color: var(--ink-red); }
.field-err:not(:empty) { margin-top: 7px; }
.tip { color: var(--text-2); }
.tip:not(:empty) { margin-top: 7px; }
.tip .link { padding: 6px 0; font-weight: 600; }
.caps { color: var(--text-2); }
.caps:not(:empty) { margin-top: 6px; }

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

.extras { display: grid; gap: 10px; }
.extras:not(:empty) { margin-top: 18px; }
.extra {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 3fr) 40px;
  gap: 8px;
  align-items: start;
}
.extra .input { padding: 0 13px; }
.extra .field-err { grid-column: 1 / -1; margin-top: -2px; }
.extra .field-err:empty { display: none; }
.remove {
  display: grid;
  place-items: center;
  width: 40px;
  height: 50px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--text-2);
  cursor: pointer;
  touch-action: manipulation;
}
.remove svg { width: 18px; height: 18px; }
.remove:hover { color: var(--ink-red); background: rgba(216, 56, 42, .07); }

.add-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 42px;
  margin: 12px 0 0 -10px;
  padding: 0 12px 0 8px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--ink-blue);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}
.add-field svg { width: 20px; height: 20px; }
.add-field:hover { background: rgba(27, 70, 194, .07); }
.extras-full { margin-top: 12px; color: var(--text-2); font-size: 14px; }

/* ------------------------------------------------------------------ actions */

.primary {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 54px;
  margin-top: 26px;
  padding: 0 20px;
  border: 0;
  border-radius: 13px;
  background: var(--ink-black);
  color: #fff;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: .01em;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12), 0 8px 18px -8px rgba(43, 40, 38, .6);
  transition: background-color .15s ease, transform .12s ease, box-shadow .15s ease;
}
.primary:hover { background: #3b3633; }
.primary:active { transform: translateY(1px); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .1), 0 4px 10px -6px rgba(43, 40, 38, .6); }
.primary:focus-visible { outline-offset: 3px; }
.primary[aria-disabled="true"],
.primary[aria-disabled="true"]:hover,
.primary[aria-disabled="true"]:active { cursor: progress; background: #47423e; transform: none; }
.input[readonly] { cursor: default; }
.back:disabled { cursor: default; opacity: .5; }
.back:disabled:hover { color: var(--text-2); background: none; }
.spinner {
  display: none;
  flex: none;
  width: 17px;
  height: 17px;
  border: 2px solid rgba(255, 255, 255, .3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .75s linear infinite;
}
.primary.busy .spinner { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }

.switch {
  margin-top: 22px;
  color: var(--text-2);
  font-size: 15px;
  text-align: center;
}
.link {
  display: inline;
  margin: 0;
  padding: 6px 2px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--ink-blue);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.link:hover { text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 3px; }

.noscript {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 9;
  padding: 14px 16px;
  border-radius: 12px;
  background: #fff;
  color: #2b2826;
  font-size: 16px;
}

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

@media (max-width: 480px) {
  .top { min-height: 58px; }
  .stage { padding-top: 14px; }
  .card {
    margin: 2vh 0 auto;
    padding: 32px 22px 22px;
    border-radius: 20px;
    /* a shorter drop shadow: the footer sits just below the card here */
    box-shadow:
      0 0 0 1px var(--card-edge),
      0 1px 2px rgba(30, 20, 10, .08),
      0 16px 34px -16px var(--wall-shadow);
  }
  .form { margin-top: 22px; }
  .primary { margin-top: 24px; }
  .switch { margin-top: 18px; }
  .extra { grid-template-columns: minmax(0, 4fr) minmax(0, 5fr) 40px; }
  .extra .input { padding: 0 11px; }
}
@media (max-width: 340px) {
  .extra { grid-template-columns: minmax(0, 1fr) 40px; }
  .extra .input + .input { grid-column: 1; grid-row: 2; }
}

/* short landscape phones: keep the card near the top */
@media (max-height: 560px) and (orientation: landscape) {
  .card { margin-top: 0; }
}

/* ------------------------------------------------------------------ motion */

@media (prefers-reduced-motion: no-preference) {
  .card { animation: card-in .5s var(--ease) both; }
  .wallboard { animation: board-in .9s ease-out both; }
  .enter-next { animation: slide-next .3s var(--ease) both; }
  .enter-back { animation: slide-back .3s var(--ease) both; }
  .enter-fade { animation: fade-up .3s var(--ease) both; }
  .extra.enter { animation: fade-up .22s var(--ease) both; }
}
@keyframes card-in { from { opacity: 0; transform: translateY(14px) scale(.985); } }
@keyframes board-in { from { opacity: 0; } }
@keyframes slide-next { from { opacity: 0; transform: translateX(18px); } }
@keyframes slide-back { from { opacity: 0; transform: translateX(-18px); } }
@keyframes fade-up { from { opacity: 0; transform: translateY(6px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; }
  .spinner { animation-duration: 1.6s; }
}
