/* 朱湘疆数竞工作室 · Atelier Portal Visual System v3
 * Aesthetic: Quiet Academic Luxury · Understated, Youthful, Substantive
 * Strictly CSP-safe (zero inline styles; all state via classes & data attributes)
 */

@font-face {
  font-family: 'WuWeiText';
  src: url('./wuwei-regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'WuWeiText';
  src: url('./wuwei-semibold.woff2') format('woff2');
  font-weight: 500 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --at-bg: #f6f6f4;
  --at-bg-card: rgba(255, 255, 255, 0.94);
  --at-ink: #121826;
  --at-ink-soft: #495569;
  --at-ink-muted: #768296;
  --at-ink-faint: #9aa4b4;
  --at-cobalt: #1d3e8a;
  --at-cobalt-mist: rgba(29, 62, 138, 0.08);
  --at-jade: #156d49;
  --at-jade-soft: rgba(21, 109, 73, 0.09);
  --at-rose: #a73342;
  --at-rose-soft: rgba(167, 51, 66, 0.08);
  --at-line: rgba(18, 24, 38, 0.075);
  --at-line-strong: rgba(18, 24, 38, 0.13);
  --at-specular: inset 0 1px 0 rgba(255, 255, 255, 0.96);
  --at-shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 6px 20px -8px rgba(15, 23, 42, 0.06);
  --at-shadow-md: 0 2px 6px rgba(15, 23, 42, 0.04), 0 24px 56px -18px rgba(15, 23, 42, 0.10);
  --at-shadow-lg: 0 4px 12px rgba(15, 23, 42, 0.05), 0 34px 78px -26px rgba(15, 23, 42, 0.14);
  --at-radius-sm: 12px;
  --at-radius-lg: 26px;
  --at-ease-spring: cubic-bezier(0.22, 1, 0.36, 1);
  --at-ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --at-font-sans: 'WuWeiText', -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  color-scheme: light;
}

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

html {
  scroll-behavior: smooth;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body.atelier-body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--at-font-sans);
  color: var(--at-ink);
  background-color: var(--at-bg);
  background-image:
    radial-gradient(ellipse 68% 54% at 14% 8%, rgba(218, 233, 250, 0.54), transparent 64%),
    radial-gradient(ellipse 52% 46% at 88% 14%, rgba(243, 238, 229, 0.62), transparent 60%),
    radial-gradient(ellipse 60% 50% at 62% 94%, rgba(226, 236, 248, 0.38), transparent 65%),
    linear-gradient(180deg, #fafaf8 0%, #f4f5f7 52%, #f6f6f4 100%);
  background-attachment: fixed;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

[hidden] {
  display: none !important;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--at-cobalt);
  outline-offset: 3px;
}

/* =========================================================
 * Top Bar — Minimal Hairline Navigation
 * ========================================================= */

.atelier-nav {
  position: sticky;
  top: 0;
  z-index: 40;
  width: 100%;
  background: rgba(249, 249, 247, 0.78);
  border-bottom: 1px solid var(--at-line);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
}

.atelier-nav-inner {
  max-width: 1180px;
  margin: 0 auto;
  height: 62px;
  padding: 0 clamp(20px, 4vw, 44px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.atelier-brand {
  display: inline-flex;
  align-items: center;
  flex: none;
  border-radius: 10px;
  transition: opacity 180ms var(--at-ease-out);
}

.atelier-brand:hover {
  opacity: 0.84;
}

.atelier-brand-logo {
  display: block;
  height: 30px;
  width: auto;
  max-width: 196px;
  object-fit: contain;
}

/* =========================================================
 * Main Shell & State Transitions
 * ========================================================= */

.atelier-main {
  flex: 1 0 auto;
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: clamp(26px, 4.4vh, 52px) clamp(20px, 4vw, 44px) 36px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.atelier-loading {
  min-height: 52vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--at-ink-muted);
  font-size: 13.5px;
}

.atelier-spinner {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid rgba(29, 62, 138, 0.14);
  border-top-color: var(--at-cobalt);
  animation: atelier-spin 780ms linear infinite;
}

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

@keyframes atelier-enter {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes atelier-fade-scale {
  from { opacity: 0; transform: translateY(8px) scale(0.988); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.stage-anonymous:not([hidden]) {
  animation: atelier-enter 480ms var(--at-ease-spring) both;
}

/* =========================================================
 * Quiet Gallery Split + Porcelain Auth
 * ========================================================= */

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.16fr) minmax(356px, 0.84fr);
  gap: clamp(32px, 4.6vw, 72px);
  align-items: center;
}

.hero-editorial {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}

.hero-copy {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.hero-title {
  margin: 0;
  font-size: clamp(38px, 4.2vw, 54px);
  line-height: 1.18;
  font-weight: 700;
  letter-spacing: -0.024em;
  color: var(--at-ink);
}

.hero-title strong {
  font-weight: 700;
}

.hero-subtitle {
  margin: 0;
  font-size: 15px;
  line-height: 1.65;
  color: var(--at-ink-soft);
}

.hero-sculpture-frame {
  position: relative;
  margin: 4px 0 0;
  border-radius: var(--at-radius-lg);
  overflow: hidden;
  border: 1px solid var(--at-line);
  background: #f1f2f4;
  box-shadow: var(--at-shadow-lg);
  aspect-ratio: 16 / 10.6;
}

.hero-sculpture-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 54%;
  transform: scale(1.01);
  transition: transform 900ms var(--at-ease-spring);
}

.hero-sculpture-frame:hover .hero-sculpture-img {
  transform: scale(1.035);
}

.hero-sculpture-frame::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72), inset 0 0 0 1px rgba(18, 24, 38, 0.04);
  pointer-events: none;
}

/* =========================================================
 * Porcelain Auth Card
 * ========================================================= */

.auth-column {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.auth-card {
  position: relative;
  background: var(--at-bg-card);
  border: 1px solid var(--at-line);
  border-radius: var(--at-radius-lg);
  padding: 30px 30px 26px;
  box-shadow: var(--at-shadow-md), var(--at-specular);
  backdrop-filter: saturate(160%) blur(18px);
  -webkit-backdrop-filter: saturate(160%) blur(18px);
  animation: atelier-fade-scale 520ms var(--at-ease-spring) 40ms both;
}

.mode-switch {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 4px;
  margin-bottom: 22px;
  border-radius: 14px;
  background: #eff1f5;
  border: 1px solid rgba(18, 24, 38, 0.045);
}

.mode-switch-thumb {
  position: absolute;
  top: 4px;
  left: 4px;
  bottom: 4px;
  width: calc(50% - 4px);
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
  transition: transform 300ms var(--at-ease-spring);
  pointer-events: none;
}

.auth-card[data-mode='register'] .mode-switch-thumb {
  transform: translateX(100%);
}

.mode-switch-btn {
  position: relative;
  z-index: 1;
  border: 0;
  background: transparent;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--at-ink-soft);
  transition: color 180ms var(--at-ease-out);
}

.mode-switch-btn[aria-selected='true'] {
  color: var(--at-ink);
  font-weight: 600;
}

.auth-header {
  margin-bottom: 18px;
}

.auth-header h1,
.auth-header h2 {
  margin: 0 0 4px;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--at-ink);
  line-height: 1.25;
}

.auth-subtitle {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--at-ink-muted);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-card.is-switching .auth-form {
  animation: atelier-fade-scale 240ms var(--at-ease-spring);
}

.kind-fieldset {
  border: 0;
  margin: 0;
  padding: 0;
}

.kind-fieldset legend {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--at-ink-soft);
  margin-bottom: 8px;
  padding: 0;
}

.kind-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.kind-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 13px;
  border-radius: var(--at-radius-sm);
  border: 1px solid var(--at-line-strong);
  background: #f9fafb;
  cursor: pointer;
  transition: border-color 180ms var(--at-ease-out), background-color 180ms var(--at-ease-out), box-shadow 180ms var(--at-ease-out);
}

.kind-option:hover {
  background: #ffffff;
  border-color: rgba(29, 62, 138, 0.28);
}

.kind-option:has(input:checked) {
  background: #ffffff;
  border-color: var(--at-cobalt);
  box-shadow: 0 0 0 3px var(--at-cobalt-mist);
}

.kind-option input[type='radio'] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--at-cobalt);
  flex: none;
}

.kind-copy {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.kind-copy strong {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--at-ink);
  line-height: 1.3;
}

.kind-copy small {
  font-size: 11px;
  color: var(--at-ink-muted);
  line-height: 1.3;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
}

.field-label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--at-ink-soft);
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.field input[type='text'],
.field input[type='password'],
.field input:not([type]) {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border-radius: var(--at-radius-sm);
  border: 1px solid var(--at-line-strong);
  background: #f8f9fb;
  color: var(--at-ink);
  font-size: 15px;
  line-height: 1.4;
  outline: none;
  transition: border-color 180ms var(--at-ease-out), background-color 180ms var(--at-ease-out), box-shadow 180ms var(--at-ease-out);
}

.input-wrap.has-toggle input {
  padding-right: 44px;
}

.field input:hover {
  border-color: rgba(18, 24, 38, 0.24);
  background: #fcfcfd;
}

.field input:focus {
  background: #ffffff;
  border-color: var(--at-cobalt);
  box-shadow: 0 0 0 4px var(--at-cobalt-mist);
}

.field input::placeholder {
  color: var(--at-ink-faint);
}

.password-toggle {
  position: absolute;
  right: 6px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--at-ink-muted);
  display: grid;
  place-items: center;
  transition: background-color 160ms var(--at-ease-out), color 160ms var(--at-ease-out);
}

.password-toggle:hover {
  background: rgba(18, 24, 38, 0.055);
  color: var(--at-ink);
}

.password-toggle svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.pw-rules {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}

.pw-rule {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  color: var(--at-ink-muted);
  background: #f1f3f6;
  transition: background-color 200ms var(--at-ease-out), color 200ms var(--at-ease-out);
}

.pw-rule::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.45;
}

.pw-rule.is-met {
  color: var(--at-jade);
  background: var(--at-jade-soft);
}

.pw-rule.is-met::before {
  opacity: 1;
}

.auth-message {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--at-rose);
  border-radius: var(--at-radius-sm);
}

.auth-message:empty {
  display: none;
}

.auth-message:not(:empty) {
  padding: 10px 13px;
  background: var(--at-rose-soft);
  border: 1px solid rgba(167, 51, 66, 0.16);
  animation: atelier-fade-scale 220ms var(--at-ease-spring);
}

.auth-message.is-success:not(:empty) {
  color: var(--at-jade);
  background: var(--at-jade-soft);
  border-color: rgba(21, 109, 73, 0.18);
}

.atelier-primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 48px;
  padding: 0 22px;
  margin-top: 2px;
  border: 1px solid rgba(18, 24, 38, 0.9);
  border-radius: 999px;
  background: linear-gradient(180deg, #1b2436 0%, #111827 100%);
  color: #ffffff;
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: 0.015em;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12), 0 12px 28px -10px rgba(17, 24, 39, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.16);
  transition: background 220ms var(--at-ease-out), border-color 220ms var(--at-ease-out), transform 160ms var(--at-ease-spring), box-shadow 220ms var(--at-ease-out);
}

.atelier-primary-btn:hover:not(:disabled) {
  background: linear-gradient(180deg, #244a9e 0%, #1a387d 100%);
  border-color: #1a387d;
  box-shadow: 0 2px 4px rgba(29, 62, 138, 0.16), 0 16px 34px -10px rgba(29, 62, 138, 0.36), inset 0 1px 0 rgba(255, 255, 255, 0.22);
  transform: translateY(-1px);
}

.atelier-primary-btn:active:not(:disabled) {
  transform: translateY(0) scale(0.985);
}

.atelier-primary-btn:disabled {
  opacity: 0.62;
  cursor: wait;
}

.atelier-btn-arrow {
  display: inline-block;
  transition: transform 220ms var(--at-ease-spring);
}

.atelier-primary-btn:hover:not(:disabled) .atelier-btn-arrow {
  transform: translateX(3px);
}

.recovery-disclosure {
  margin-top: 2px;
  border-top: 1px solid var(--at-line);
  padding-top: 12px;
}

.recovery-disclosure summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--at-ink-muted);
  cursor: pointer;
  padding: 2px 0;
  transition: color 180ms var(--at-ease-out);
}

.recovery-disclosure summary::-webkit-details-marker {
  display: none;
}

.recovery-disclosure summary:hover,
.recovery-disclosure[open] summary {
  color: var(--at-ink);
}

.recovery-chevron {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  transition: transform 240ms var(--at-ease-spring);
}

.recovery-disclosure[open] .recovery-chevron {
  transform: rotate(180deg);
}

.recovery-disclosure p {
  margin: 10px 0 0;
  padding: 11px 13px;
  border-radius: var(--at-radius-sm);
  background: #f5f7fa;
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--at-ink-soft);
  animation: atelier-fade-scale 240ms var(--at-ease-spring);
}

/* =========================================================
 * Footer
 * ========================================================= */

.atelier-footer {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 16px clamp(20px, 4vw, 44px) 24px;
  border-top: 1px solid var(--at-line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 20px;
  font-size: 12px;
  color: var(--at-ink-muted);
}

/* =========================================================
 * Responsive Craft — Tablet & Mobile (390x844 Above-the-Fold)
 * ========================================================= */

@media (max-width: 980px) {
  .atelier-main {
    justify-content: flex-start;
  }

  .hero-grid {
    grid-template-columns: 1fr;
    gap: 24px;
  }
}

@media (max-width: 720px) {
  .atelier-nav-inner {
    height: 52px;
    padding: 0 16px;
    gap: 8px;
  }

  .atelier-brand-logo {
    height: 24px;
    max-width: 148px;
  }

  .atelier-main {
    padding: 14px 16px 28px;
  }

  /* Compact architectural hero strip: sculpture + title side-by-side so full login card + submit button fit inside 390x844 */
  .hero-grid {
    gap: 14px;
  }

  .hero-editorial {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 114px;
    gap: 12px;
    align-items: center;
  }

  .hero-copy {
    gap: 4px;
  }

  .hero-title {
    font-size: 24px;
    line-height: 1.24;
    letter-spacing: -0.018em;
  }

  .hero-subtitle {
    font-size: 12.5px;
    line-height: 1.48;
  }

  .hero-sculpture-frame {
    margin: 0;
    width: 114px;
    aspect-ratio: 4 / 3;
    border-radius: 14px;
    box-shadow: var(--at-shadow-sm);
  }

  .auth-card {
    padding: 18px 18px 16px;
    border-radius: 20px;
  }

  .mode-switch {
    margin-bottom: 14px;
  }

  .mode-switch-btn {
    padding: 7px 10px;
    font-size: 13px;
  }

  .auth-header {
    margin-bottom: 12px;
  }

  .auth-header h1,
  .auth-header h2 {
    font-size: 20px;
    margin-bottom: 2px;
  }

  .auth-subtitle {
    font-size: 12px;
  }

  .auth-form {
    gap: 11px;
  }

  .field {
    gap: 5px;
  }

  /* 16px font-size prevents iOS Safari auto-zoom on input focus */
  .field input[type='text'],
  .field input[type='password'],
  .field input:not([type]) {
    font-size: 16px;
    height: 44px;
  }

  .atelier-primary-btn {
    min-height: 46px;
  }

  .recovery-disclosure {
    padding-top: 10px;
  }

  .atelier-footer {
    padding: 14px 16px 22px;
    font-size: 11.5px;
    gap: 4px 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
