/* ==========================================================================
   M杰克日记 — 后台登录页
   个人博客风格：暖色纸感底纹 + 衬线标题 + 简洁登录卡片
   ========================================================================== */

:root {
  --paper: #f7f4ef;
  --paper-deep: #efe9e1;
  --card: #fffdfa;

  --ink: #2a2521;
  --ink-soft: #5f574f;
  --muted: #948a80;
  --faint: #b3a99e;

  --line: #eae3da;
  --line-strong: #dbd2c6;

  --accent: #b4593a;
  --accent-dark: #9a472c;
  --accent-soft: #f5e8e1;

  --danger: #b3261e;
  --danger-bg: #fdf4f2;
  --danger-line: #f0cfc9;
  --warn: #96631c;

  --radius-lg: 18px;
  --radius-md: 10px;
  --radius-sm: 7px;

  --shadow-card: 0 22px 48px -28px rgba(74, 58, 44, 0.38), 0 2px 6px rgba(74, 58, 44, 0.04);
  --shadow-focus: 0 0 0 3px rgba(180, 89, 58, 0.13);

  --font-serif: "Noto Serif SC", "Songti SC", "STSong", "SimSun", "Source Han Serif SC",
    Georgia, "Times New Roman", serif;
  --font-sans: "Inter", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC",
    system-ui, -apple-system, sans-serif;
}

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

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink-soft);
  background-color: #2a2438;
  background-image: url("./wallpaper.svg");
  background-size: cover;
  background-position: center 58%;
  background-repeat: no-repeat;
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* 壁纸上的柔光罩：保证文字与卡片可读，同时保留插画氛围 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(
      60% 50% at 50% 44%,
      rgba(255, 251, 245, 0.72) 0%,
      rgba(255, 251, 245, 0.32) 55%,
      rgba(255, 251, 245, 0) 100%
    ),
    linear-gradient(
      180deg,
      rgba(255, 250, 243, 0.58) 0%,
      rgba(255, 250, 243, 0.26) 34%,
      rgba(255, 250, 243, 0.34) 66%,
      rgba(255, 250, 243, 0.88) 100%
    );
}

h1,
h2,
h3,
p,
ul,
li {
  margin: 0;
  padding: 0;
}

ul {
  list-style: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

::selection {
  background: rgba(180, 89, 58, 0.16);
}

/* --------------------------------------------------------------------------
   页面骨架
   -------------------------------------------------------------------------- */
.page {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 44px 20px 26px;
}

.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

/* --------------------------------------------------------------------------
   飘落花瓣
   -------------------------------------------------------------------------- */
.petals {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.petals span {
  position: absolute;
  top: -8vh;
  width: 12px;
  height: 12px;
  border-radius: 62% 4% 62% 4%;
  background: linear-gradient(140deg, #ffdbe5 0%, #f9a9c0 60%, #ef8fae 100%);
  opacity: 0;
  animation: petal-fall 24s linear infinite;
  filter: drop-shadow(0 1px 2px rgba(150, 80, 100, 0.12));
}

.petals span:nth-child(1) {
  left: 6%;
  width: 11px;
  height: 11px;
  animation-duration: 26s;
  animation-delay: 0s;
}

.petals span:nth-child(2) {
  left: 21%;
  width: 14px;
  height: 14px;
  animation-duration: 31s;
  animation-delay: 5s;
}

.petals span:nth-child(3) {
  left: 37%;
  width: 9px;
  height: 9px;
  animation-duration: 22s;
  animation-delay: 11s;
}

.petals span:nth-child(4) {
  left: 58%;
  width: 13px;
  height: 13px;
  animation-duration: 29s;
  animation-delay: 3s;
}

.petals span:nth-child(5) {
  left: 76%;
  width: 10px;
  height: 10px;
  animation-duration: 25s;
  animation-delay: 14s;
}

.petals span:nth-child(6) {
  left: 91%;
  width: 12px;
  height: 12px;
  animation-duration: 33s;
  animation-delay: 8s;
}

@keyframes petal-fall {
  0% {
    transform: translate3d(0, 0, 0) rotate(0deg);
    opacity: 0;
  }
  8% {
    opacity: 0.75;
  }
  50% {
    transform: translate3d(-46px, 58vh, 0) rotate(160deg);
  }
  88% {
    opacity: 0.55;
  }
  100% {
    transform: translate3d(64px, 118vh, 0) rotate(320deg);
    opacity: 0;
  }
}

/* --------------------------------------------------------------------------
   博客标识
   -------------------------------------------------------------------------- */
.intro {
  margin-bottom: 26px;
  text-align: center;
  animation: fade-up 0.55s cubic-bezier(0.22, 0.61, 0.36, 1) both;
}

.avatar {
  position: relative;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin: 0 auto 18px;
  border-radius: 50%;
  overflow: hidden;
  font-family: var(--font-serif);
  font-size: 27px;
  font-weight: 600;
  line-height: 1;
  color: #fffaf5;
  background: linear-gradient(145deg, #c9764f 0%, #ad5132 55%, #98452a 100%);
  box-shadow:
    0 0 0 6px rgba(180, 89, 58, 0.08),
    0 12px 26px -14px rgba(150, 69, 44, 0.75),
    inset 0 1px 0 rgba(255, 255, 255, 0.28);
  user-select: none;
}

.avatar__letter {
  display: block;
  line-height: 1;
}

.avatar__img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.site-title {
  font-family: var(--font-serif);
  font-size: 27px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--ink);
  text-shadow: 0 1px 18px rgba(255, 255, 255, 0.85);
}

.site-tagline {
  margin-top: 10px;
  font-size: 13px;
  letter-spacing: 0.02em;
  color: var(--ink-soft);
  text-shadow: 0 1px 12px rgba(255, 255, 255, 0.75);
}

/* --------------------------------------------------------------------------
   登录卡片
   -------------------------------------------------------------------------- */
.card {
  width: 100%;
  max-width: 388px;
  padding: 27px 28px 22px;
  background: rgba(255, 253, 250, 0.93);
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(10px) saturate(1.06);
  -webkit-backdrop-filter: blur(10px) saturate(1.06);
  animation: fade-up 0.55s cubic-bezier(0.22, 0.61, 0.36, 1) 0.08s both;
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card.is-shaking {
  animation: shake 0.42s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes shake {
  10%,
  90% {
    transform: translateX(-1px);
  }
  20%,
  80% {
    transform: translateX(3px);
  }
  30%,
  50%,
  70% {
    transform: translateX(-5px);
  }
  40%,
  60% {
    transform: translateX(5px);
  }
}

.card__head h2 {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--ink);
}

/* --------------------------------------------------------------------------
   错误提示
   -------------------------------------------------------------------------- */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin-top: 16px;
  padding: 10px 12px;
  border: 1px solid var(--danger-line);
  border-radius: var(--radius-md);
  background: var(--danger-bg);
  color: var(--danger);
  animation: alert-in 0.24s ease-out both;
}

.alert.is-locked {
  border-color: #ecd9b8;
  background: #fdf8ee;
  color: var(--warn);
}

@keyframes alert-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.alert__icon {
  flex: 0 0 auto;
  margin-top: 2px;
}

.alert__body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12.5px;
  line-height: 1.65;
}

.alert__body strong {
  font-size: 12.5px;
  font-weight: 600;
}

.alert__body span {
  opacity: 0.92;
}

/* --------------------------------------------------------------------------
   表单
   -------------------------------------------------------------------------- */
#login-form {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-top: 20px;
}

.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--ink-soft);
}

.control {
  position: relative;
  display: flex;
  align-items: center;
  height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: #fffefc;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.control:hover {
  border-color: #c9bfb2;
}

.control:focus-within {
  border-color: var(--accent);
  background: #ffffff;
  box-shadow: var(--shadow-focus);
}

.control__icon {
  flex: 0 0 auto;
  margin: 0 9px 0 12px;
  color: var(--faint);
  transition: color 0.18s ease;
}

.control:focus-within .control__icon {
  color: var(--accent);
}

.control input {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0 12px 0 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--ink);
}

.control input::placeholder {
  color: var(--faint);
  font-size: 12.5px;
}

.control input:-webkit-autofill,
.control input:-webkit-autofill:hover,
.control input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--ink);
  -webkit-box-shadow: 0 0 0 60px #fffefc inset;
}

.control__action {
  display: grid;
  place-items: center;
  width: 36px;
  height: 100%;
  margin-right: 3px;
  border-radius: var(--radius-sm);
  color: var(--faint);
  transition: color 0.16s ease, background 0.16s ease;
}

.control__action:hover {
  color: var(--accent);
  background: rgba(180, 89, 58, 0.07);
}

.field__hint {
  margin-top: 5px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--danger);
}

.field__hint:empty {
  display: none;
}

.field.is-invalid .control {
  border-color: var(--danger-line);
  background: #fffbfa;
}

.field.is-invalid .control:focus-within {
  border-color: #dc9d93;
  box-shadow: 0 0 0 3px rgba(179, 38, 30, 0.11);
}

/* --------------------------------------------------------------------------
   选项行
   -------------------------------------------------------------------------- */
.options {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 1px;
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

.checkbox input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.checkbox__box {
  display: grid;
  place-items: center;
  width: 15px;
  height: 15px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: #fffefc;
  color: transparent;
  transition: all 0.16s ease;
}

.checkbox:hover .checkbox__box {
  border-color: #c9a08f;
}

.checkbox input:checked + .checkbox__box {
  border-color: var(--accent);
  background: var(--accent);
  color: #fffaf5;
}

.checkbox input:focus-visible + .checkbox__box {
  box-shadow: var(--shadow-focus);
}

.link {
  padding: 0;
  font-size: 12.5px;
  color: var(--accent);
  transition: color 0.16s ease;
}

.link:hover {
  color: var(--accent-dark);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

/* --------------------------------------------------------------------------
   提交按钮
   -------------------------------------------------------------------------- */
.submit {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  margin-top: 5px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.16em;
  color: #fffaf5;
  background: linear-gradient(180deg, #c26844 0%, var(--accent) 55%, #a54e30 100%);
  box-shadow:
    0 10px 20px -12px rgba(154, 71, 44, 0.8),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
  transition: transform 0.14s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

.submit:hover:not(:disabled) {
  filter: brightness(1.04);
  box-shadow:
    0 14px 24px -12px rgba(154, 71, 44, 0.85),
    inset 0 1px 0 rgba(255, 255, 255, 0.24);
}

.submit:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: 0 6px 12px -10px rgba(154, 71, 44, 0.9);
}

.submit:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.submit:disabled {
  cursor: not-allowed;
  filter: saturate(0.6) brightness(1.02);
  opacity: 0.8;
}

.submit__spinner {
  display: none;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 250, 245, 0.4);
  border-top-color: #fffaf5;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.submit.is-loading .submit__spinner {
  display: block;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* --------------------------------------------------------------------------
   页脚
   -------------------------------------------------------------------------- */
.footer {
  margin-top: 30px;
  font-size: 11.5px;
  letter-spacing: 0.02em;
  color: var(--muted);
  text-align: center;
  text-shadow: 0 1px 10px rgba(255, 255, 255, 0.9);
}

/* --------------------------------------------------------------------------
   弹窗
   -------------------------------------------------------------------------- */
.dialog {
  width: min(420px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--card);
  box-shadow: 0 34px 70px -30px rgba(74, 58, 44, 0.5);
  color: var(--ink-soft);
}

.dialog::backdrop {
  background: rgba(42, 37, 33, 0.42);
  backdrop-filter: blur(2px);
}

.dialog[open] {
  animation: dialog-in 0.22s cubic-bezier(0.22, 0.61, 0.36, 1) both;
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.dialog__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 17px 20px 13px;
  border-bottom: 1px solid var(--line);
}

.dialog__head h3 {
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--ink);
}

.dialog__close {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  color: var(--faint);
  transition: background 0.16s ease, color 0.16s ease;
}

.dialog__close:hover {
  background: var(--paper-deep);
  color: var(--ink-soft);
}

.dialog__body {
  padding: 16px 20px;
  font-size: 13px;
  line-height: 1.85;
  color: var(--ink-soft);
}

.dialog__body p + p {
  margin-top: 9px;
}

.dialog__body strong {
  color: var(--ink);
  font-weight: 600;
}

.dialog__foot {
  display: flex;
  justify-content: flex-end;
  padding: 0 20px 18px;
}

.btn-ghost {
  height: 32px;
  padding: 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  color: var(--ink-soft);
  background: #fffefc;
  transition: border-color 0.16s ease, background 0.16s ease, color 0.16s ease;
}

.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
  background: var(--accent-soft);
}

/* --------------------------------------------------------------------------
   响应式
   -------------------------------------------------------------------------- */
@media (max-width: 480px) {
  .page {
    padding: 32px 16px 20px;
  }

  .avatar {
    width: 58px;
    height: 58px;
    font-size: 24px;
    margin-bottom: 15px;
  }

  .site-title {
    font-size: 23px;
  }

  .card {
    padding: 24px 20px 20px;
  }

  .footer {
    margin-top: 22px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
