/* Mobile signed-out -- v12 Frame 12.
 *
 * Loaded alongside login.css on /login. Active at <=767px (matches the
 * global .u-mobile-only / .u-desktop-only breakpoint in app.css). Above
 * that breakpoint the existing login.css desktop layout wins -- tablets
 * (768-1023px) get the existing single-column form (no brand panel until
 * 1024px), which has shipped for months.
 *
 * The HTML in login.html keeps the desktop tree intact under .u-desktop-only
 * and renders a mobile-only header + footer under .u-mobile-only. This file
 * styles the .u-mobile-only nodes + adapts the shared form (.login-form /
 * .login-input / .login-btn / .login-error) to match the v12 mockup.
 *
 * Brand-primary, surface, and text tokens come from app.css :root + the
 * dark override on <html data-theme="dark">.
 */

@media (max-width: 767px) {

  /* ===== Screen frame ================================================== */
  body { background: var(--bg-app); margin: 0; padding: 0; }

  .login-screen {
    background: var(--bg-app);
    align-items: stretch;
    justify-content: stretch;
    padding: 0;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    min-height: 100dvh;
  }
  .login-split {
    display: flex;
    flex-direction: column;
    width: 100%;
    padding: 0 20px;
  }

  /* The desktop brand panel is hidden via the .u-desktop-only utility -- this
     is defence-in-depth in case that utility ever loses to specificity. */
  .login-brand { display: none !important; }

  /* The .login-box was a centred 380px card on the gradient. On mobile it's
     the whole pane -- transparent, full width, vertical stack. */
  .login-box {
    background: transparent;
    box-shadow: none;
    padding: 0;
    max-width: none;
    width: 100%;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    text-align: left;
  }

  /* ===== Mobile header (logo + name + tagline) ========================= */
  .login-mobile-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 32px 0 24px;
    flex: 1 1 auto;
  }
  .login-mobile-header__name {
    font-size: 30px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.024em;
    text-align: center;
    margin: 4px 0 0;
  }
  .login-mobile-header__tagline {
    font-size: 16px;
    color: var(--text-secondary);
    text-align: center;
    margin: -6px 0 0;
    line-height: 1.4;
    letter-spacing: -0.005em;
  }

  /* Building-silhouette logo (v12 .dpg-logo). 104x104 brand-primary square
     with a white house silhouette inside. */
  .dpg-logo {
    width: 104px;
    height: 104px;
    border-radius: 24px;
    background: var(--brand-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(15, 76, 129, 0.16),
                0 6px 16px rgba(15, 76, 129, 0.20);
    color: #ffffff;
    position: relative;
  }
  .dpg-logo__mark {
    width: 56px;
    height: 56px;
    fill: currentColor;
  }
  [data-theme="dark"] .dpg-logo {
    background: #1f3a5f;
    color: #93c5fd;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5),
                0 6px 16px rgba(147, 197, 253, 0.20);
  }

  /* ===== Form card (Email + Password + Sign in + Forgot password) ====== */
  .login-form {
    background: var(--bg-surface);
    border: 1px solid var(--border-card);
    border-radius: 16px;
    padding: 18px 16px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    margin: 0 auto 16px;
    width: 100%;
    max-width: 340px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    text-align: left;
  }

  .login-field { display: flex; flex-direction: column; gap: 6px; }
  .login-field__lbl {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-tertiary);
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }

  .login-input {
    width: 100%;
    height: 48px;
    padding: 0 14px;
    border: 1px solid var(--border-card);
    border-radius: 12px;
    background: var(--bg-hover);
    color: var(--text-primary);
    font-size: 16px;
    outline: none;
    font-family: inherit;
    letter-spacing: -0.005em;
  }
  .login-input::placeholder { color: var(--text-tertiary); }
  .login-input:focus { border-color: var(--brand-primary); }
  [data-theme="dark"] .login-input {
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--border-card);
    color: var(--text-primary);
  }
  [data-theme="dark"] .login-input:focus { border-color: #93c5fd; }

  .login-error {
    font-size: 13px;
    color: var(--severity-critical, #c62828);
    line-height: 1.4;
  }
  .login-error:empty { display: none; }
  [data-theme="dark"] .login-error { color: #f87171; }

  .login-btn {
    width: 100%;
    height: 48px;
    border: 0;
    border-radius: 12px;
    background: var(--brand-primary);
    color: var(--text-inverse, #ffffff);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    letter-spacing: -0.005em;
    margin-top: 4px;
  }
  .login-btn:disabled { opacity: 0.6; cursor: not-allowed; }
  [data-theme="dark"] .login-btn {
    background: #93c5fd;
    color: #0d1117;
  }

  .login-forgot {
    background: transparent;
    border: 0;
    color: var(--brand-primary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    padding: 4px;
    align-self: center;
    text-decoration: none;
  }
  [data-theme="dark"] .login-forgot { color: #93c5fd; }

  /* ===== Mobile footer (lang seg + Secured · v<sha>) =================== */
  .login-mobile-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 0 0 14px;
  }

  .login-lang-seg {
    display: flex;
    gap: 2px;
    background: var(--bg-hover);
    border: 1px solid var(--border-subtle);
    border-radius: 11px;
    padding: 3px;
    height: 34px;
    width: 100%;
    max-width: 260px;
  }
  [data-theme="dark"] .login-lang-seg {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.06);
  }
  .login-lang-seg__opt {
    flex: 1 1 0;
    height: 26px;
    padding: 0 10px;
    border-radius: 8px;
    border: 0;
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    letter-spacing: -0.005em;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
  }
  .login-lang-seg__opt--active {
    background: var(--bg-surface);
    color: var(--text-primary);
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06),
                0 1px 1px rgba(15, 23, 42, 0.04);
  }
  [data-theme="dark"] .login-lang-seg__opt--active {
    background: rgba(147, 197, 253, 0.18);
    color: #93c5fd;
  }

  .login-secured {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-tertiary);
    font-family: -apple-system, "SF Pro Text", BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, system-ui, sans-serif;
  }

  /* The .login-footer (desktop trouble + toggle button) is hidden via the
     .u-desktop-only utility -- defence-in-depth keeps it offscreen even if
     that utility ever loses to specificity. */
  .login-footer { display: none !important; }
  .login-desktop-header { display: none !important; }

  /* ===== Light + Dark visual sanity ==================================== */
  body { color-scheme: light dark; }
}

@media (max-width: 767px) and (prefers-color-scheme: dark) {
  /* If the user hasn't picked an explicit theme yet, follow OS preference
     so the login page still reads correctly. The base.html pre-paint script
     stamps data-theme when localStorage has a choice -- without it we honour
     the OS hint here so a dark-mode phone never lands on a white login. */
  html:not([data-theme]) {
    --bg-app: #0d1117;
    --bg-surface: #161b22;
    --bg-hover: #1f242c;
    --border-card: #2d333b;
    --border-subtle: #21262d;
    --text-primary: #f0f3f6;
    --text-secondary: #b8c0cc;
    --text-tertiary: #8590a0;
  }
}
