/* Login gate (js/auth-gate.js). Uses the variables from app.css. */

/* Until someone is signed in the app is hidden (and `inert`, set in JS). */
body.auth-locked { overflow: hidden; }
body.auth-locked > header,
body.auth-locked > main { visibility: hidden; }

.gate {
  position: fixed; inset: 0; z-index: 30;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  display: grid; place-items: center;
  padding: calc(20px + env(safe-area-inset-top)) 16px calc(20px + env(safe-area-inset-bottom));
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(43, 74, 203, 0.10), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, rgba(29, 122, 70, 0.08), transparent 60%),
    var(--bg);
}
.gate[hidden] { display: none; }

.gate-card {
  width: min(920px, 100%);
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  background: var(--panel); border: 1px solid var(--line); border-radius: 22px;
  box-shadow: 0 2px 4px rgba(30, 30, 20, 0.05), 0 24px 70px rgba(30, 30, 20, 0.12);
  overflow: hidden;
}

/* ---- left: what the app does */
.gate-intro {
  padding: 36px 34px; display: flex; flex-direction: column; gap: 14px;
  background:
    repeating-linear-gradient(to bottom, transparent 0 31px, rgba(43, 74, 203, 0.07) 31px 32px),
    #f8f6f0;
  border-right: 1px solid var(--line);
}
.gate-brand { display: flex; align-items: center; gap: 10px; font-weight: 750; font-size: 22px; letter-spacing: -0.01em; }
.gate-brand svg { width: 34px; height: 34px; color: var(--accent); }
.gate-claim { margin: 0; font-size: 26px; line-height: 1.2; font-weight: 700; letter-spacing: -0.02em; }
.gate-sample { width: 100%; max-width: 340px; height: auto; margin: 4px 0; }
.gate-ink {
  fill: none; stroke: #1f2f6b; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 1; stroke-dashoffset: 1; animation: gate-write 0.32s calc(0.3s + var(--i) * 0.3s) ease-in-out forwards;
}
@keyframes gate-write { to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) { .gate-ink { animation: none; stroke-dashoffset: 0; } }
.gate-points { margin: 0; padding-left: 22px; display: grid; gap: 6px; font-weight: 600; color: #3d4352; }
.gate-points li::marker { color: var(--accent); font-weight: 750; }
.gate-why { margin: auto 0 0; color: var(--muted); font-size: 14px; }

/* ---- right: forms */
.gate-main { padding: 32px 34px; display: flex; flex-direction: column; gap: 12px; min-height: 460px; }
.gate-main h2 { margin: 0; font-size: 24px; letter-spacing: -0.01em; }
.gate-main p { margin: 0; }
.gate-main > p, .gate-form > p { line-height: 1.45; }
.gate-main[data-view="loading"], .gate-main[data-view="syncing"], .gate-main[data-view="offline"] { justify-content: center; }
.gate-center { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; }
.gate-icon { font-size: 40px; line-height: 1; }
.gate-main[data-view="check"] .gate-icon { align-self: flex-start; }

.gate-tabs { display: flex; background: #eeebe3; border-radius: 12px; padding: 4px; margin-bottom: 6px; }
.gate-tabs button {
  flex: 1; border: 0; background: transparent; min-height: 42px; border-radius: 9px;
  font-weight: 650; font-size: 15px; cursor: pointer; color: #4b5161; touch-action: manipulation;
}
.gate-tabs button[aria-selected="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); }
.gate-tabs button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.gate-form { display: flex; flex-direction: column; gap: 12px; }
.gate-field { display: flex; flex-direction: column; gap: 5px; }
.gate-field label { font-weight: 600; font-size: 14px; color: #3d4352; }
.gate-field input {
  width: 100%; min-height: 48px; padding: 0 14px; font-size: 16px; /* 16px: no zoom on iPhone */
  border: 1px solid #d6d1c4; border-radius: 12px; background: #fff; color: var(--ink);
}
.gate-field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(43, 74, 203, 0.18); }
.gate-field input[aria-invalid="true"] { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(179, 38, 30, 0.12); }
.gate-hint { color: var(--muted); font-size: 12.5px; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 52px; }
.pw-toggle {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 44px; height: 40px; border: 0; background: transparent; border-radius: 9px;
  color: var(--muted); cursor: pointer; display: grid; place-items: center;
}
.pw-toggle:hover, .pw-toggle:focus-visible { color: var(--ink); background: #f1efe8; outline: none; }
.pw-toggle svg { width: 22px; height: 22px; }
.pw-toggle .eye-off { opacity: 0; }
.pw-toggle[aria-pressed="true"] .eye-off { opacity: 1; }

.gate-code { text-align: center; font-size: 26px !important; letter-spacing: 0.35em; font-variant-numeric: tabular-nums; font-weight: 650; }
.gate-code::placeholder { color: #d4d0c5; }

.gate-submit { min-height: 50px; font-size: 16px; border-radius: 12px; width: 100%; }
.gate-submit:disabled, .gate-continue:disabled { opacity: 0.65; cursor: default; }
.gate-continue { min-height: 46px; border-radius: 12px; width: 100%; }
.gate-forgot { align-self: center; padding: 6px; }
.gate-links { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.gate-links .link { padding: 6px 0; min-height: 34px; }
.link:disabled { color: var(--muted); cursor: default; }

.gate-msg:empty { display: none; }
.gate-msg { font-size: 14px; font-weight: 600; }
.gate-msg[data-kind="error"] { color: var(--danger); }
.gate-msg[data-kind="ok"] { color: var(--ok); }
.gate-notice { background: #fff7e6; border: 1px solid #f0d9a8; color: #6b4a00; border-radius: 10px; padding: 9px 12px; font-size: 14px; }
.gate-net { background: #fff7e6; border: 1px solid #f0d9a8; color: #6b4a00; border-radius: 10px; padding: 9px 12px; font-size: 14px; }
.gate-local { font-size: 13px; color: var(--ok); background: #eef7f1; border: 1px solid #cfe7d8; border-radius: 10px; padding: 8px 12px; }
.gate-addr { overflow-wrap: anywhere; }

.gate-spinner {
  display: inline-block; width: 18px; height: 18px; border-radius: 50%; vertical-align: -3px; margin-right: 8px;
  border: 2.5px solid currentColor; border-right-color: transparent; animation: gate-spin 0.8s linear infinite;
}
.gate-center .gate-spinner { width: 34px; height: 34px; margin: 0; color: var(--accent); border-width: 3px; }
@keyframes gate-spin { to { transform: rotate(360deg); } }

/* Offline banner below the top bar (returning user without connection). */
.offline-banner {
  position: sticky; top: 0; z-index: 9;
  background: #fff7e6; color: #6b4a00; border-bottom: 1px solid #f0d9a8;
  padding: 8px 20px; font-size: 13.5px; font-weight: 600; text-align: center;
}
.offline-banner[hidden] { display: none; }

@media (max-width: 760px) {
  .gate { place-items: start center; }
  .gate-card { grid-template-columns: 1fr; border-radius: 18px; }
  .gate-intro { padding: 22px 22px 18px; border-right: 0; border-bottom: 1px solid var(--line); gap: 8px; background: #f8f6f0; }
  .gate-claim { font-size: 20px; }
  .gate-sample, .gate-points, .gate-why { display: none; }
  .gate-main { padding: 22px; min-height: 0; }
  .gate-main h2 { font-size: 21px; }
}
