/* Shared login/register safe-area layout. Keep long forms in normal flow. */
.auth-header {
  padding-top: calc(env(safe-area-inset-top, 0px) + var(--nav-top));
}
@media (max-width: 760px), (pointer: coarse) {
  .auth-page {
    --auth-safe-top: max(32px, env(safe-area-inset-top, 0px));
    --auth-header-height: calc(var(--auth-safe-top) + 91px);
  }
  .auth-header {
    position: relative;
    min-height: var(--auth-header-height);
    padding: calc(var(--auth-safe-top) + 12px) max(20px, env(safe-area-inset-right, 0px)) 16px max(20px, env(safe-area-inset-left, 0px));
    animation: none;
  }
  .auth-header .brand img {
    width: 180px;
    max-width: 56vw;
    height: auto;
    margin: 0;
  }
  .auth-stage {
    min-height: calc(100svh - var(--auth-header-height));
    padding-top: 12px;
  }
}
@media (max-width: 760px) {
  .auth-stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 32px;
    padding: 0 max(14px, env(safe-area-inset-right, 0px)) max(24px, env(safe-area-inset-bottom, 0px)) max(14px, env(safe-area-inset-left, 0px));
  }
  .auth-column {
    flex: none;
    min-height: calc(100svh - var(--auth-header-height) - max(24px, env(safe-area-inset-bottom, 0px)));
    grid-template-rows: minmax(24px, 1fr) auto minmax(72px, 1fr);
    align-content: stretch;
  }
  .auth-card { grid-row: 2; width: 100%; }
  .auth-foot { grid-row: 3; align-self: start; }
  .auth-intro { flex: none; width: 100%; }
}
@media (max-width: 760px) {
  .auth-card { min-width: 0; grid-template-columns: minmax(0, 1fr); }
  .auth-card :is(.login-panel, .register-panel, .turnstile-zone, .turnstile-shell) { min-width: 0; }
}
@media (max-width: 379px) {
  .auth-card .turnstile-shell { grid-template-columns: minmax(0, 1fr); width: 100%; height: 60px; min-height: 60px; }
  .auth-card #turnstile-widget { width: 300px; transform: scale(.9); transform-origin: top center; }
}
@media (max-width: 359px) {
  .auth-card .turnstile-shell { height: 52px; min-height: 52px; }
  .auth-card #turnstile-widget { transform: scale(.8); }
}

/* Match Anime's rounded type, including form controls and saved accounts. */
@font-face {
  font-family: "Aulama Rounded HK";
  src: url("/anime/fonts/resource-han-rounded-hk-heavy.ttf") format("truetype");
  font-style: normal;
  font-weight: 900;
  font-display: swap;
}
@font-face {
  font-family: "Aulama Rounded CN";
  src: url("/anime/fonts/resource-han-rounded-cn-heavy.ttf") format("truetype");
  font-style: normal;
  font-weight: 900;
  font-display: swap;
}
.auth-page { --auth-rounded-font: "Aulama Rounded HK", "PingFang TC", sans-serif; font-family: var(--auth-rounded-font); }
html[lang="zh-CN"] .auth-page, html[lang="zh-Hans"] .auth-page {
  --auth-rounded-font: "Aulama Rounded CN", "PingFang SC", sans-serif;
}
.auth-page :is(button, input, select, textarea) { font-family: var(--auth-rounded-font); }

/* The image overlays its initial; it must not create a second grid row. */
.auth-page .device-account-avatar { position: relative; }
.auth-page .device-account-avatar > span { grid-area: 1 / 1; }
.auth-page .device-account-avatar > img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

/* Keep the brand above scrolling content; fade blur beyond the header edge. */
.auth-header { isolation: isolate; }
.auth-header::before {
  content: "";
  position: absolute;
  inset: 0 0 -36px;
  z-index: -1;
  pointer-events: none;
  background: linear-gradient(to bottom, var(--bg) 0%, color-mix(in srgb, var(--bg) 88%, transparent) 35%, color-mix(in srgb, var(--bg) 55%, transparent) 70%, transparent);
  -webkit-backdrop-filter: blur(22px) saturate(1.25);
  backdrop-filter: blur(22px) saturate(1.25);
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, #000 55%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 0%, #000 55%, transparent 100%);
  opacity: var(--auth-scroll-shade, 0);
}
@media (max-width: 760px), (pointer: coarse) {
  .auth-header { position: sticky; top: 0; }
}
@media (prefers-reduced-transparency: reduce) {
  .auth-header::before { -webkit-backdrop-filter: none; backdrop-filter: none; }
}
