/* Sign-in screen B "Invitation" (TD-0043, approved 18 Oct): cobalt with a dot matrix, lime routes
   converging on a coral point, the headline with its handwritten line, the feature badges and the
   white card with the form or the loading state. Used by the front door at / (index.html,
   sign-in.js, with its static loading scene #signin-boot), the sign-in over the workspace
   (auth.js) and the workspace's loading screen (#app-boot-layer in workspace.html); markup in
   sign-in-layer.js. Tokens: ./brand/tokens.css, fonts: ./brand/fonts/fonts.css. Rules:
   docs/4_BRAND.md. */

/* Front door page: cobalt from the first paint, before sign-in.js draws the scene. */
.signin-page {
  min-height: 100dvh;
  margin: 0;
  background-color: var(--cobalt);
  background-image: radial-gradient(rgba(255, 255, 255, 0.16) 1.3px, transparent 1.7px);
  background-size: 16px 16px;
}

/* The scene: a fixed layer that scrolls on its own (over the workspace too). #signin-boot is the
   front door's static copy with the loading card (index.html), until sign-in.js draws the layer. */
.auth-layer,
.app-boot-layer,
.signin-boot {
  position: fixed;
  inset: 0;
  overflow: auto;
  overscroll-behavior: contain;
}

/* Above everything in the workspace — top bar 3100, day card 3400, comments 3500, share 3600,
   Feedback 3700: a visitor's "Sign in" opens it over whatever is open (P54). */
.auth-layer {
  z-index: 3800;
}

.app-boot-layer,
.signin-boot {
  z-index: 3200;
}

.auth-layer.is-hidden,
.app-boot-layer.is-hidden,
.signin-scene [hidden] {
  display: none !important;
}

.signin-scene {
  background: var(--cobalt);
  color: #ffffff;
  font: 400 15px/1.5 var(--f-ui);
  -webkit-font-smoothing: antialiased;
  text-align: left;
}

.signin-shell {
  position: relative;
  display: flex;
  min-height: 100%;
  flex-direction: column;
  overflow-x: clip;
  background-image: radial-gradient(rgba(255, 255, 255, 0.16) 1.3px, transparent 1.7px);
  background-size: 16px 16px;
}

.signin-scene :where(p, h1, h2, ul) {
  margin: 0;
}

.signin-icon {
  width: 18px;
  height: 18px;
  flex: none;
}

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

/* Keyboard focus: lime on cobalt, cobalt on white (beats theme-v3.css's cobalt ring). */
.signin-scene :where(button, a, input):focus-visible {
  outline: 3px solid var(--lime) !important;
  outline-offset: 2px;
}

.signin-card :where(button, a):focus-visible,
.signin-lang-menu :where(button):focus-visible {
  outline-color: var(--cobalt) !important;
}

/* Decoration: dotted routes and the pulsing point they meet in. */
.signin-arcs {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.signin-arcs-routes path {
  fill: none;
  stroke: var(--lime);
  stroke-dasharray: 2 9;
  stroke-linecap: round;
  stroke-width: 2.5;
}

.signin-arcs-ring,
.signin-arcs-pulse {
  fill: none;
  stroke: var(--coral);
  stroke-width: 2;
}

.signin-arcs-ring {
  stroke-dasharray: 4 6;
}

.signin-arcs-pulse {
  transform-box: fill-box;
  transform-origin: center;
  vector-effect: non-scaling-stroke;
  animation: signin-pulse 2.4s ease-out infinite;
}

.signin-arcs-point {
  fill: var(--coral);
  stroke: #ffffff;
  stroke-width: 3;
}

@keyframes signin-pulse {
  from { opacity: 0.9; transform: scale(0.4); }
  to { opacity: 0; transform: scale(2.2); }
}

/* Top bar: the wordmark, the visitor's way back and the language. Ink like the app's top bar and
   the home page's footer (P68), over the cobalt scene. */
.signin-top {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 40px;
  background: var(--ink);
}

/* The logo (P59, white ticket on ink). On a narrow phone with the Back button (a long word,
   e.g. Finnish) it gives way, scaled down in its box, instead of pushing the pills into the margin. */
.signin-wordmark {
  display: block;
  width: auto;
  min-width: 0;
  height: 30px;
  flex: 0 1 auto;
  object-fit: contain;
  object-position: left center;
}

/* The logo is a link to the public home page (owner, 19 Oct; site-links.js): it gives way like the
   logo did; the keyboard focus ring is the scene's lime one. */
.signin-home {
  display: flex;
  min-width: 0;
  flex: 0 1 auto;
  border-radius: 6px;
  color: inherit;
}

.signin-top-actions {
  display: flex;
  flex: none;
  align-items: center;
  gap: 10px;
}

/* Visitor's way back from the sign-in to the idea under it (P54). */
.landing-back {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  border: 1.5px solid rgba(255, 255, 255, 0.45);
  border-radius: 999px;
  padding: 0 12px 0 7px;
  background: transparent;
  color: #ffffff;
  cursor: pointer;
  font: 600 13px/1 var(--f-ui);
}

.landing-back .signin-icon {
  width: 16px;
  height: 16px;
}

.landing-back:hover {
  border-color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
}

/* Only the active language; a click opens the list of all UI languages (TD-0031). */
.signin-lang {
  position: relative;
}

.signin-lang-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 0;
  border-radius: 999px;
  padding: 3px 8px 3px 3px;
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  cursor: pointer;
  font: 500 12px/1 var(--f-mono);
}

.signin-lang-button:hover,
.signin-lang-button[aria-expanded="true"] {
  background: rgba(255, 255, 255, 0.24);
}

.signin-lang-button.is-static {
  padding-right: 3px;
  cursor: default;
}

/* A finger-sized target around the small pills. */
.signin-lang-button::after,
.landing-back::after {
  position: absolute;
  inset: -7px;
  content: "";
}

.signin-lang-code {
  display: block;
  border-radius: 999px;
  padding: 6px 9px;
  background: var(--lime);
  color: var(--ink);
  font-weight: 500;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.signin-lang-button .signin-icon {
  width: 14px;
  height: 14px;
}

.signin-lang-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 5;
  display: grid;
  width: 220px;
  max-height: calc(100dvh - 90px);
  overflow-y: auto;
  overscroll-behavior: contain;
  gap: 2px;
  border-radius: 14px;
  padding: 6px;
  /* All 19 languages fit on a desktop. Where the list scrolls (phones), a shade at the edge shows
     that it goes on, also where overlay scrollbars (iOS, macOS) show no bar: the white covers
     (local) scroll away with the list, so the shade shows only where there is more. */
  background:
    linear-gradient(var(--card) 30%, rgba(255, 255, 255, 0)) center top / 100% 36px no-repeat local,
    linear-gradient(rgba(255, 255, 255, 0), var(--card) 70%) center bottom / 100% 36px no-repeat local,
    radial-gradient(farthest-side at 50% 0, rgba(14, 16, 32, 0.22), rgba(14, 16, 32, 0)) center top / 100% 14px no-repeat scroll,
    radial-gradient(farthest-side at 50% 100%, rgba(14, 16, 32, 0.22), rgba(14, 16, 32, 0)) center bottom / 100% 14px no-repeat scroll,
    var(--card);
  box-shadow: var(--sh-3);
}

.signin-lang-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: 9px;
  padding: 8px 10px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font: 500 14px/1.2 var(--f-ui);
  text-align: left;
}

.signin-lang-menu b {
  width: 38px;
  color: var(--ink-3);
  font: 500 11px/1 var(--f-mono);
  letter-spacing: 0.06em;
}

.signin-lang-menu button:hover,
.signin-lang-menu button[aria-checked="true"] {
  background: var(--cobalt-50);
  color: var(--cobalt-ink);
}

/* Hero and card side by side; on phones the card first (below). */
.signin-main {
  position: relative;
  z-index: 1;
  display: grid;
  width: 100%;
  max-width: 1240px;
  grid-template-columns: minmax(0, 1.1fr) minmax(340px, 440px);
  align-items: center;
  gap: 48px;
  margin: 0 auto;
  padding: 40px 40px 60px;
}

.signin-kicker {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font: 500 12px/1 var(--f-mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.signin-kicker-tile {
  display: grid;
  width: 28px;
  height: 28px;
  flex: none;
  place-items: center;
  border-radius: 8px;
  background: #ffffff;
  color: var(--cobalt);
  font-family: var(--f-ui);
  letter-spacing: 0;
}

.signin-title {
  margin: 22px 0 18px;
  color: #ffffff;
  font: 800 clamp(48px, 7vw, 96px)/0.92 var(--f-display);
  letter-spacing: -0.045em;
}

.signin-hand {
  display: block;
  color: var(--lime);
  font: 700 clamp(44px, 6vw, 80px)/0.92 var(--f-hand);
  letter-spacing: 0;
  transform: rotate(-3deg);
  transform-origin: left;
}

.signin-lead {
  max-width: 520px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 18px;
  line-height: 1.5;
}

.signin-features {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 26px;
  padding: 0;
  list-style: none;
}

.signin-feature {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border-radius: 9px;
  padding: 7px 11px;
  font: 500 12px/1 var(--f-mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.signin-feature .signin-icon {
  width: 15px;
  height: 15px;
}

/* Badge colours as approved; text in each colour's AA pair (--dN-text, docs/4_BRAND.md). */
.signin-feature--route { background: var(--card); color: var(--cobalt); }
.signin-feature--days { background: var(--d2); color: var(--d2-text); }
.signin-feature--stays { background: var(--ink); color: var(--card); }
.signin-feature--people { background: var(--coral); color: var(--ink); }
.signin-feature--costs { background: var(--lime); color: var(--ink); }
.signin-feature--tasks { background: var(--d3); color: var(--d3-text); }
.signin-feature--comments { background: var(--d6); color: var(--d6-text); }

/* Scripts without the brand fonts' glyphs: system fallbacks, no negative tracking (docs/4_BRAND.md). */
.signin-title:is(:lang(ja), :lang(ko), :lang(zh), :lang(ru), :lang(uk)),
.signin-card-title:is(:lang(ja), :lang(ko), :lang(zh), :lang(ru), :lang(uk)) {
  letter-spacing: 0;
}

/* Japanese, Korean and Chinese: the system glyphs are taller and fill the em box, so the lines get
   room (the tilted handwritten line would touch the first one) and the size steps down. Korean
   wraps between words, Japanese between phrases (no lone "を" or "ン。"), in the lead too. */
.signin-title:is(:lang(ja), :lang(ko), :lang(zh)) {
  font-size: clamp(40px, 5.4vw, 74px);
  line-height: 1.12;
}

.signin-title:is(:lang(ja), :lang(ko), :lang(zh)) .signin-hand {
  margin-top: 0.08em;
  font-size: clamp(36px, 4.6vw, 64px);
  line-height: 1.12;
  transform: rotate(-2deg);
}

:is(.signin-title, .signin-lead):lang(ko) {
  word-break: keep-all;
}

:is(.signin-title, .signin-lead):lang(ja) {
  word-break: auto-phrase;
}

/* The card: the form, or the loading state (sign, "One moment", progress). */
.signin-card {
  border-radius: 26px;
  padding: 30px 30px 24px;
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--sh-3);
}

.signin-scene:not(.is-loading) .signin-loading,
.signin-scene.is-loading .signin-ready {
  display: none;
}

.signin-eyebrow {
  color: var(--ink-3);
  font: 500 11px/1.4 var(--f-mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.signin-card-title {
  margin: 10px 0 6px;
  color: var(--ink);
  font: 800 34px/1 var(--f-display);
  letter-spacing: -0.03em;
}

.signin-card-copy {
  margin-bottom: 20px;
  color: var(--ink-2);
  font-size: 15px;
  line-height: 1.5;
}

.signin-sign {
  display: block;
  width: 44px;
  height: 44px;
  margin-bottom: 18px;
}

.signin-loading .signin-card-copy {
  margin-bottom: 0;
}

.signin-progress {
  display: block;
  height: 4px;
  margin: 26px 0 4px;
  overflow: hidden;
  border-radius: 99px;
  background: var(--cobalt-50);
}

.signin-progress::after {
  display: block;
  width: 40%;
  height: 100%;
  border-radius: inherit;
  background: var(--cobalt);
  content: "";
  animation: signin-progress 1.2s ease-in-out infinite;
}

@keyframes signin-progress {
  from { transform: translateX(-100%); }
  to { transform: translateX(250%); }
}

.signin-label {
  display: grid;
  gap: 6px;
  margin: 0 0 14px;
  color: var(--ink);
  font: 600 13px/1 var(--f-ui);
}

.signin-field {
  display: flex;
  height: 48px;
  align-items: center;
  gap: 10px;
  border: 1.5px solid var(--line-2);
  border-radius: 12px;
  padding: 0 14px;
  background: var(--card);
  color: var(--ink-3);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.signin-field:focus-within {
  border-color: var(--cobalt);
  box-shadow: 0 0 0 3px var(--cobalt-50);
  color: var(--ink);
}

.signin-field input {
  width: 100%;
  min-width: 0;
  height: 100%;
  flex: 1;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--ink);
  font: 500 15px/1 var(--f-ui);
}

/* The field's ring is the focus indicator. */
.signin-field input:focus,
.signin-field input:focus-visible {
  outline: none !important;
}

/* Primary action: cobalt with a dashed stub (docs/4_BRAND.md, buttons). */
.signin-submit {
  display: flex;
  width: 100%;
  height: 50px;
  align-items: stretch;
  margin-top: 6px;
  border: 0;
  border-radius: 14px;
  padding: 0;
  background: var(--cobalt);
  color: #ffffff;
  cursor: pointer;
  font: 600 15px/1 var(--f-ui);
}

.signin-submit:hover {
  background: var(--cobalt-ink);
}

.signin-submit:disabled {
  cursor: wait;
  opacity: 0.6;
}

.signin-submit-label {
  display: grid;
  flex: 1;
  place-items: center;
}

.signin-stub {
  display: grid;
  width: 52px;
  flex: none;
  place-items: center;
  border-left: 2px dashed rgba(255, 255, 255, 0.45);
}

.auth-status {
  margin-top: 10px;
  color: var(--ink-3);
  font-size: 13px;
  line-height: 1.45;
}

.auth-status:empty {
  display: none;
}

.auth-status.is-error {
  color: var(--coral-ink);
}

.auth-status.is-success {
  color: var(--ink);
}

.signin-or {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0;
  color: var(--ink-3);
  font: 500 11px/1 var(--f-mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.signin-or::before,
.signin-or::after {
  flex: 1;
  border-top: 1.5px dashed var(--line-2);
  content: "";
}

/* The demo: the second way in, as visible as signing in — lime, ink frame, offset shadow, stub. */
.signin-demo {
  display: flex;
  min-height: 58px;
  align-items: stretch;
  border: 2px solid var(--ink);
  border-radius: 14px;
  background: var(--lime);
  color: var(--ink);
  box-shadow: 0 4px 0 var(--ink);
  text-decoration: none;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.signin-demo:hover {
  color: var(--ink);
  transform: translateY(-1px);
  box-shadow: 0 5px 0 var(--ink);
}

.signin-demo:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--ink);
}

.signin-demo-body {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
}

.signin-demo-body > .signin-icon {
  width: 22px;
  height: 22px;
}

.signin-demo-title {
  display: block;
  font: 700 16px/1.15 var(--f-ui);
}

.signin-demo-note {
  display: block;
  margin-top: 2px;
  color: var(--ink-2);
  font: 500 11px/1.2 var(--f-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.signin-demo .signin-stub {
  border-left-color: var(--ink);
}

.signin-note {
  margin-top: 16px;
  color: var(--ink-3);
  font-size: 13px;
  line-height: 1.5;
}

.signin-note a {
  color: var(--cobalt-ink);
  text-decoration: underline;
}

/* Loading screens: texts show once they are in the visitor's language (the workspace: auth.js;
   the front door: sign-in.js replaces the static scene), at the latest after 2.5 s in the page's
   own words. */
.app-boot-layer:not(.is-translated) :is([data-i18n], [data-locale-code]),
.signin-boot :is([data-i18n], [data-locale-code]) {
  visibility: hidden;
  animation: signin-reveal 0s 2.5s forwards;
}

@keyframes signin-reveal {
  to { visibility: visible; }
}

/* Phones: the card first, then the headline and the badges (the lead stays on wider screens). */
@media (max-width: 860px) {
  .signin-top {
    padding: 18px 20px;
  }

  .signin-wordmark {
    height: 22px;
  }

  /* The card keeps a cobalt gap under the ink top bar. */
  .signin-main {
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
    padding: 18px 18px 40px;
  }

  .signin-hero {
    order: 2;
  }

  .signin-card {
    order: 1;
  }

  .signin-lead {
    display: none;
  }

  .signin-features {
    margin-top: 18px;
  }

  .signin-title {
    margin: 16px 0 0;
    font-size: 46px;
  }

  .signin-hand {
    font-size: 44px;
  }

  /* 16 px: phones do not zoom into the field. */
  .signin-field input {
    font-size: 16px;
  }

  /* Loading: the card is short and the headline moves up, so the routes meet behind the card
     (as they do behind the form) instead of on the handwritten line. */
  .signin-scene.is-loading .signin-arcs {
    bottom: auto;
    height: 440px;
  }
}

@media (max-width: 380px) {
  .signin-card {
    padding: 24px 20px 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .signin-arcs-pulse {
    display: none;
  }

  /* No sliding: the bar breathes in place. */
  .signin-progress::after {
    width: 100%;
    animation: signin-breathe 1.6s ease-in-out infinite alternate;
  }

  .signin-demo {
    transition: none;
  }
}

@keyframes signin-breathe {
  from { opacity: 0.25; }
  to { opacity: 0.75; }
}
