/* Sign-in: a full-bleed photographic sea cliff (WebGL2, 2.5D) with one liquid-glass card over the open sky (right on
   desktop, low on phones). Day and night are the same place, pixel-aligned; the theme crossfades the photographs.
   Ported from the approved design (haytham-landing.html); fonts are self-hosted (CSP 'self'). */
@font-face { font-family: "Newsreader"; src: url(fonts/newsreader.woff2) format("woff2"); font-weight: 400 500; font-style: normal; font-display: swap; }
@font-face { font-family: "Geist"; src: url(fonts/geist.woff2) format("woff2"); font-weight: 400 600; font-style: normal; font-display: swap; }
@font-face { font-family: "Geist Mono"; src: url(fonts/geist-mono.woff2) format("woff2"); font-weight: 400 500; font-style: normal; font-display: swap; }
:root {
  --ink: #13202e; --ink-soft: #3e4b5a; --line: rgba(19,32,46,.16);
  --btn-bg: #13202e; --btn-fg: #f4f6f8; --btn-hover: #24364a; --link: #13202e;
  --focus: #b0702a; --err: #a2321c;
  --glass: rgba(246,248,251,.74); --glass-edge: rgba(255,255,255,.85);
  --seg-bg: rgba(255,255,255,.55); --seg-on: #13202e; --seg-on-fg: #f4f6f8; --seg-fg: #13202e;
  --page: #cfe0ef;
  --display: "Newsreader", "Iowan Old Style", Georgia, serif;
  --ui: "Geist", "Helvetica Neue", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #e8edf3; --ink-soft: #a9b5c3; --line: rgba(232,237,243,.16);
    --btn-bg: #e8edf3; --btn-fg: #0d1624; --btn-hover: #ffffff; --link: #e8edf3; --focus: #d9a35f; --err: #ff9c86;
    --glass: rgba(14,22,36,.72); --glass-edge: rgba(190,210,235,.22);
    --seg-bg: rgba(14,22,36,.55); --seg-on: #e8edf3; --seg-on-fg: #0d1624; --seg-fg: #e8edf3;
    --page: #0b1220; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ink: #e8edf3; --ink-soft: #a9b5c3; --line: rgba(232,237,243,.16);
  --btn-bg: #e8edf3; --btn-fg: #0d1624; --btn-hover: #ffffff; --link: #e8edf3; --focus: #d9a35f; --err: #ff9c86;
  --glass: rgba(14,22,36,.72); --glass-edge: rgba(190,210,235,.22);
  --seg-bg: rgba(14,22,36,.55); --seg-on: #e8edf3; --seg-on-fg: #0d1624; --seg-fg: #e8edf3;
  --page: #0b1220; color-scheme: dark;
}
html, body { height: 100%; }
body { margin: 0; overflow: hidden; color: var(--ink); font-family: var(--ui); background: var(--page); -webkit-font-smoothing: antialiased; transition: color .6s ease; }

/* The still photograph: always behind; the only background without JS/WebGL and on the setup page. */
.still { position: fixed; inset: 0; background: url(scene/L-day-1920.webp) 32% 50% / cover no-repeat; }
@media (orientation: portrait) { .still { background-image: url(scene/P-day-1080.webp); background-position: 34% 40%; } }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .still { background-image: url(scene/L-night-1920.webp); } }
@media (prefers-color-scheme: dark) and (orientation: portrait) { :root:not([data-theme="light"]) .still { background-image: url(scene/P-night-1080.webp); } }
:root[data-theme="dark"] .still { background-image: url(scene/L-night-1920.webp); }
@media (orientation: portrait) { :root[data-theme="dark"] .still { background-image: url(scene/P-night-1080.webp); } }
html.js body:not(.static) .still { display: none; }
html:not(.js) .seg { display: none; }

/* JS: tiny inline placeholder, then the WebGL scene fades in */
#ph { position: fixed; inset: -40px; background-size: cover; background-repeat: no-repeat; filter: blur(18px) saturate(1.1); transform: translateZ(0); transition: opacity .8s ease; }
#sky { position: fixed; inset: 0; width: 100%; height: 100%; display: block; opacity: 0; transition: opacity .8s ease; touch-action: none; }
body.gl-ready #sky { opacity: 1; }
#photo { position: fixed; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .8s ease; }
body.photo-ready #photo { opacity: 1; }

.stage {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: flex-end;
  padding-inline: max(16px, 7vw); padding-block: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-bottom, 0px));
  overflow-y: auto; pointer-events: none;
}
.card {
  pointer-events: auto; position: relative; box-sizing: border-box;
  width: min(380px, 100%); padding: 38px 34px 24px; border-radius: 26px; text-align: center;
  display: grid; gap: 16px; justify-items: center;
  /* fallback glass (no WebGL, setup page); replaced by refraction in the shader */
  background: var(--glass); border: 1px solid var(--glass-edge);
  -webkit-backdrop-filter: blur(22px) saturate(1.1); backdrop-filter: blur(22px) saturate(1.1);
  box-shadow: 0 20px 50px rgba(10,20,35,.16);
}
body.gl-ready .card { background: transparent; border-color: transparent; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
.mark { width: 40px; height: 40px; display: block; color: var(--ink); }
.word { margin: 2px 0 0; font-family: var(--display); font-weight: 400; font-size: clamp(42px, 5.6vw, 52px); line-height: 1; letter-spacing: .005em; font-variation-settings: "opsz" 72; }
.word.small { font-size: 34px; font-variation-settings: "opsz" 48; }
.sub { margin: -6px 0 0; font-family: var(--mono); font-size: 11px; font-weight: 500; letter-spacing: .2em; text-transform: uppercase; color: var(--ink-soft); }
.greet { margin: 4px 0 2px; font-size: 15px; line-height: 1.55; max-width: 30ch; text-wrap: pretty; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; height: 46px; padding: 0 18px; width: 100%; box-sizing: border-box;
  background: var(--btn-bg); color: var(--btn-fg); border: 0; border-radius: 12px; cursor: pointer; text-decoration: none;
  font: 500 15px/1 var(--ui); letter-spacing: .005em; transition: background .2s ease, transform .15s ease;
}
.btn:hover { background: var(--btn-hover); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .6; cursor: progress; }
.btn svg { width: 19px; height: 19px; flex: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.alt { background: none; border: 0; padding: 4px 6px; margin-top: -4px; color: var(--link); font: 500 13.5px/1.2 var(--ui); cursor: pointer; text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 4px; }
.alt:hover { text-decoration-color: currentColor; }
.pw { display: none; width: 100%; gap: 10px; text-align: left; }
.card.pw-open .pw, .pw.open { display: grid; }
.card.pw-open .alt { display: none; }
.card.no-passkey #passkey { display: none; }
.pw label { font-size: 12px; font-weight: 500; color: var(--ink-soft); display: grid; gap: 5px; }
.pw input { height: 42px; box-sizing: border-box; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: transparent; color: var(--ink); font: 400 15px var(--ui); }
.pw input[readonly] { color: var(--ink-soft); }
.pw input:focus-visible { outline-offset: 1px; }
.pw .btn { height: 42px; margin-top: 2px; }
.msg { margin: -4px 0 0; min-height: 1.2em; font-size: 13px; line-height: 1.4; }
.msg:empty { display: none; }
.msg.err { color: var(--err); font-weight: 500; }
.foot { margin: 4px 0 0; padding-top: 12px; border-top: 1px solid var(--line); width: 100%; font-size: 11.5px; line-height: 1.5; color: var(--ink-soft); }
.foot i { font-family: var(--display); font-style: italic; font-size: 13px; color: var(--ink); }

/* theme switch: Auto / Day / Night */
.seg { position: fixed; top: max(16px, env(safe-area-inset-top, 0px)); right: 16px; display: flex; padding: 3px; gap: 2px; border-radius: 999px; background: var(--seg-bg); border: 1px solid var(--glass-edge); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); z-index: 2; }
.seg button { border: 0; background: none; color: var(--seg-fg); font: 500 12px/1 var(--ui); letter-spacing: .02em; padding: 7px 11px; border-radius: 999px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--seg-on); color: var(--seg-on-fg); }
.brand { position: fixed; top: max(18px, env(safe-area-inset-top, 0px)); left: 16px; margin: 0; font-family: var(--mono); font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--ink); opacity: .75; padding: 8px 0; }

@media (max-width: 760px), (orientation: portrait) {
  .stage { justify-content: center; align-items: flex-end; padding-block: 64px max(28px, calc(env(safe-area-inset-bottom, 0px) + 20px)); }
  .card { padding: 28px 22px 18px; gap: 13px; }
  .brand { display: none; }
}
@media (max-height: 560px) { .stage { align-items: flex-start; } .card { padding: 20px 22px 14px; gap: 9px; } .greet { display: none; } }
@media (prefers-reduced-motion: reduce) { #sky, #photo, #ph, body { transition: none; } }
