/* Shared styles for the client portal sign-in and password reset pages. */

/* ------------------------------------------------------------------
   Theme tokens. To match the main site exactly, copy the matching
   colour values from /assets/css/nav.css into these two blocks.
   ------------------------------------------------------------------ */
:root {
  --sky-top:      #081424;
  --sky-bottom:   #17385a;
  --card:         #0f2137;
  --card-edge:    #243f5e;
  --ink:          #eef4fb;
  --ink-soft:     #b4c7db;
  --field:        #0a192b;
  --field-edge:   #4a6b8f;
  --accent:       #9ad4ff;
  --accent-hover: #c4e7ff;
  --accent-ink:   #05203a;
  --link:         #9ad4ff;
  --tile-on:      rgba(154, 212, 255, 0.12);
  --focus:        #ffd166;
  --ok-bg:        #0f3a2a; --ok-ink: #bdf2d6; --ok-edge: #2f7a55;
  --err-bg:       #3d1519; --err-ink: #ffd3d6; --err-edge: #8e3d44;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --sky-top:      #2b5e90;
  --sky-bottom:   #86b6de;
  --card:         #ffffff;
  --card-edge:    #d4e0ec;
  --ink:          #10263d;
  --ink-soft:     #475d74;
  --field:        #ffffff;
  --field-edge:   #7f97af;
  --accent:       #0b5cad;
  --accent-hover: #084a8c;
  --accent-ink:   #ffffff;
  --link:         #0b5cad;
  --tile-on:      #eaf3fc;
  --focus:        #c2410c;
  --ok-bg:        #e4f6ec; --ok-ink: #114f2f; --ok-edge: #8fd0ad;
  --err-bg:       #fdecee; --err-ink: #7a1d25; --err-edge: #eba9b0;
  color-scheme: light;
}

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

html { font-size: 100%; }

body {
  min-height: 100vh;
  font-family: "Trebuchet MS", sans-serif;
  line-height: 1.5;
  color: var(--ink);
  background-color: var(--sky-top);
}
body::before {
  content: "";
  position: fixed; inset: 0;
  z-index: -1;
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-bottom) 100%);
}

/* ---------- Falling snow (same idea as the home page hero) ---------- */
.snowfall {
  position: fixed; inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}
.flake {
  position: absolute;
  top: -3rem;
  color: #fff;
  line-height: 1;
  user-select: none;
  animation-name: fall;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
  text-shadow: 0 0 6px rgba(255, 255, 255, 0.35);
}
@keyframes fall {
  0%   { transform: translate3d(0, 0, 0) rotate(0deg); }
  50%  { transform: translate3d(2.5vw, 55vh, 0) rotate(90deg); }
  100% { transform: translate3d(-1.5vw, 112vh, 0) rotate(180deg); }
}
@media (prefers-reduced-motion: reduce) {
  .flake { animation: none; display: none; }
}

/* ---------- Layout ---------- */
.shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  padding: 2rem 1rem;
}
.brand img {
  display: block;
  width: 240px;
  max-width: 70vw;
  height: auto;
}

.card {
  width: 100%;
  max-width: 26rem;
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: 12px;
  padding: 2rem 1.75rem 1.75rem;
  box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.55);
}
.card h1 {
  font-size: 1.5rem;
  line-height: 1.25;
  font-weight: 700;
  margin-bottom: 0.4rem;
}
.lede {
  color: var(--ink-soft);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

/* ---------- Choice between password and code ---------- */
.method { border: 0; margin-bottom: 1.25rem; }
.method legend {
  font-weight: 700;
  font-size: 0.875rem;
  color: var(--ink-soft);
  margin-bottom: 0.5rem;
}
.tiles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}
.tile { position: relative; display: block; cursor: pointer; }
.tile input {
  position: absolute;
  opacity: 0;
  width: 1px; height: 1px;
}
.tile-body {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  height: 100%;
  padding: 0.75rem 0.8rem;
  border: 1px solid var(--field-edge);
  border-radius: 8px;
  background: var(--field);
  transition: border-color 0.15s, background-color 0.15s;
}
.tile-body svg { flex: none; width: 20px; height: 20px; stroke: var(--ink-soft); }
.tile-title { display: block; font-weight: 700; font-size: 0.9rem; line-height: 1.25; }
.tile-note  { display: block; margin-top: 0.15rem; font-size: 0.78rem; color: var(--ink-soft); line-height: 1.35; }
.tile input:checked + .tile-body {
  border-color: var(--accent);
  background: var(--tile-on);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.tile input:checked + .tile-body svg { stroke: var(--accent); }
.tile input:focus-visible + .tile-body {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

/* ---------- Messages ---------- */
.msg {
  border-radius: 6px;
  padding: 0.7rem 0.85rem;
  margin-bottom: 1rem;
  border: 1px solid;
  font-size: 0.875rem;
}
.msg[hidden] { display: none; }
.msg-ok  { background: var(--ok-bg);  color: var(--ok-ink);  border-color: var(--ok-edge); }
.msg-err { background: var(--err-bg); color: var(--err-ink); border-color: var(--err-edge); }
.msg a { color: inherit; font-weight: 700; }
.msg .inline-action {
  display: inline-block;
  margin-top: 0.6rem;
  font: inherit;
  font-weight: 700;
  color: inherit;
  background: none;
  border: 0;
  text-decoration: underline;
  cursor: pointer;
}

/* ---------- Fields ---------- */
.field { margin-bottom: 1rem; }
.field label {
  display: block;
  font-size: 0.875rem;
  font-weight: 700;
  margin-bottom: 0.3rem;
}
.field .hint {
  display: block;
  font-size: 0.8rem;
  color: var(--ink-soft);
  margin-top: 0.35rem;
}
.input {
  width: 100%;
  padding: 0.7rem 0.8rem;
  font: inherit;
  font-size: 0.9rem;
  color: var(--ink);
  background: var(--field);
  border: 1px solid var(--field-edge);
  border-radius: 6px;
}
.input:focus {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
  border-color: var(--accent);
}
.with-toggle { position: relative; }
.with-toggle .input { padding-right: 4.5rem; }
.reveal {
  position: absolute;
  top: 50%; right: 0.5rem;
  transform: translateY(-50%);
  min-height: 2rem;
  padding: 0 0.7rem;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--link);
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}
.reveal:focus-visible { outline: 3px solid var(--focus); }

.code-input {
  font-size: 1.4rem;
  letter-spacing: 0.4em;
  text-align: center;
  font-variant-numeric: tabular-nums;
  padding-left: 1.1rem; /* balances the trailing letter-spacing */
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  margin: 0.25rem 0 1.25rem;
  font-size: 0.875rem;
  cursor: pointer;
}
.check input {
  flex: none;
  width: 1.05rem;
  height: 1.05rem;
  margin-top: 0.15rem;
  accent-color: var(--accent);
  cursor: pointer;
}
.check input:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.check small { display: block; color: var(--ink-soft); font-size: 0.78rem; }

.btn {
  width: 100%;
  padding: 0.75rem;
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent-ink);
  background: var(--accent);
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.15s;
}
.btn:hover:not(:disabled) { background: var(--accent-hover); }
.btn:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.btn:disabled { opacity: 0.65; cursor: wait; }

.sent-to {
  margin-bottom: 1rem;
  padding: 0.7rem 0.85rem;
  font-size: 0.875rem;
  border-left: 3px solid var(--accent);
  background: var(--tile-on);
  border-radius: 0 6px 6px 0;
}
.sent-to strong { word-break: break-all; }

.code-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem 1.25rem;
  margin-top: 0.9rem;
}
.linkish {
  font: inherit;
  font-size: 0.85rem;
  color: var(--link);
  background: none;
  border: 0;
  padding: 0.25rem 0;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.linkish:disabled { color: var(--ink-soft); text-decoration: none; cursor: default; }
.linkish:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

.help {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--card-edge);
  font-size: 0.85rem;
}
.help a, .foot a {
  color: var(--link);
  text-underline-offset: 3px;
}
.foot a { color: #e6f1fb; }
.foot { font-size: 0.85rem; }

[hidden] { display: none !important; }

/* ---------- Theme toggle ---------- */
.theme-toggle {
  position: fixed;
  top: 1rem; right: 1rem;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.25rem;
  padding: 0 0.85rem;
  font: inherit;
  font-size: 0.8rem;
  color: #eef4fb;
  background: rgba(8, 20, 36, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  cursor: pointer;
  backdrop-filter: blur(4px);
}
.theme-toggle svg { width: 15px; height: 15px; stroke: currentColor; }
.theme-toggle:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

@media (max-width: 480px) {
  .shell { padding-top: 4rem; }
  .card { padding: 1.5rem 1.25rem; }
  .card h1 { font-size: 1.25rem; }
  .tiles { grid-template-columns: 1fr; }
  .tile-body { flex-direction: row; align-items: center; gap: 0.7rem; }
  .input { font-size: 1rem; } /* 16px stops iPhones zooming in on tap */
  .code-input { font-size: 1.3rem; letter-spacing: 0.35em; }
}

/* ---------- Admin two-step sign-in setup ---------- */
.setup-steps {
  margin: 0 0 1rem 1.2rem;
  font-size: 0.9rem;
}
.setup-steps li { margin-bottom: 0.4rem; }
.qr-box {
  width: fit-content;
  margin: 0 auto 1rem;
  padding: 12px;
  background: #ffffff;           /* QR codes need a light background in both themes */
  border-radius: 8px;
}
.qr-box img, .qr-box canvas { display: block; }
.hint-block {
  font-size: 0.85rem;
  color: var(--ink-soft);
  margin-bottom: 0.5rem;
}
.key {
  font-family: "Courier New", Courier, monospace;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  word-break: break-word;
  padding: 0.6rem 0.8rem;
  margin-bottom: 1.25rem;
  background: var(--tile-on);
  border-radius: 6px;
}
.backup-grid {
  list-style: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.backup-grid li {
  font-family: "Courier New", Courier, monospace;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-align: center;
  padding: 0.55rem 0.4rem;
  border: 1px dashed var(--field-edge);
  border-radius: 6px;
}
a.btn {
  display: block;
  text-align: center;
  text-decoration: none;
  margin-top: 0.6rem;
}
.btn-secondary {
  background: transparent;
  color: var(--link);
  border: 1px solid var(--field-edge);
}
.btn-secondary:hover:not(:disabled) { background: var(--tile-on); }
a.linkish { display: inline-block; }

@media print {
  .snowfall, .theme-toggle, .brand, .no-print, .foot { display: none !important; }
  body, body::before { background: #fff !important; }
  .card { box-shadow: none; border: 0; color: #000; }
  .backup-grid li { color: #000; border-color: #000; }
}
