/* ==========================================================================
   AUTH: 로그인·가입(/login/)과 폼 부품(내 정보에서도 씀)
   한 가지 아이디어: 두 줄기(X)는 장식이 아니라 연결 상태를 보여 주는 계기다.
   가입 폼을 채우면 두 줄기가 가운데로 모이고, 준비가 끝나면 흰 점이 켜진다.
   ========================================================================== */

/* hidden 속성이 클래스의 display 를 이기도록 */
.auth [hidden], .me [hidden], .auth-form [hidden], .confirm-box [hidden], .form-alert[hidden] { display: none !important; }

/* ---------- 공통 폼 부품 ---------- */
.auth-form { display: grid; gap: 20px; }
.auth-form .field > label { color: var(--text); font-weight: 620; font-size: .92rem; }
.auth-form .input { font-size: 1rem; }
.input[aria-invalid="true"] { border-color: color-mix(in srgb, var(--err) 70%, transparent); }
.input[aria-invalid="true"]:focus { border-color: var(--err); }
.input[aria-invalid="true"]:focus-visible { outline-color: var(--err); }
.field-error { margin: 0; display: flex; gap: 6px; align-items: flex-start; }

/* 비밀번호 보기 */
.pw { position: relative; }
.pw .input { padding-right: 54px; }
.pw-toggle {
  position: absolute; right: 3px; top: 50%; transform: translateY(-50%);
  width: 44px; height: 44px; display: grid; place-items: center;
  border: 0; border-radius: var(--r-sm); background: none; color: var(--text-3);
  transition: color var(--d-1), background var(--d-1);
}
.pw-toggle:hover { color: var(--text); background: rgb(var(--tint-rgb) / .05); }
.pw-toggle[aria-pressed="true"] { color: var(--ether); }
.pw-toggle svg { width: 20px; height: 20px; }

/* 비밀번호 조건: 짧은 실시간 힌트 두 개 */
.pw-rules { list-style: none; display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: .84rem; color: var(--text-3); }
.pw-rules li { display: inline-flex; align-items: center; gap: 7px; transition: color var(--d-2); }
.pw-rules li::before {
  content: ""; width: 14px; height: 14px; border-radius: 50%; flex: none;
  border: 1.5px solid currentColor; opacity: .7;
  transition: background var(--d-2), border-color var(--d-2), opacity var(--d-2);
}
.pw-rules li.is-ok { color: var(--ether); }
.pw-rules li.is-ok::before {
  opacity: 1; border-color: var(--ether);
  background: var(--ether) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23042019' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'><path d='M6 12.5l4 4 8-9'/></svg>") center / 10px no-repeat;
}
.pw-rules li.is-bad { color: var(--err-ink); }

/* 닉네임 상태 */
.handle-status { font-size: .84rem; color: var(--text-3); display: flex; gap: 7px; align-items: flex-start; min-height: 1.5em; }
.handle-status svg { flex: none; width: 16px; height: 16px; margin-top: 3px; }
.handle-status.is-ok { color: var(--ether); }
.handle-status.is-err { color: var(--err-ink); }
.handle-status.is-wait { color: var(--text-2); }
.handle-status .spin { margin-top: 4px; }

/* 한 줄짜리 작은 회전 표시 (사용자 행동에 답할 때만) */
.spin {
  display: inline-block; flex: none; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; opacity: .8;
  animation: auth-spin .8s linear infinite;
}
@keyframes auth-spin { to { transform: rotate(360deg); } }

/* 버튼 진행 중 */
.btn.is-busy { pointer-events: none; }
.btn.is-busy .spin { width: 16px; height: 16px; }

/* 폼 전체 알림 */
.form-alert {
  display: flex; gap: 10px; align-items: flex-start; flex-wrap: wrap;
  padding: 12px 14px; border-radius: var(--r-md);
  background: color-mix(in srgb, var(--err) 8%, transparent); border: 1px solid color-mix(in srgb, var(--err) 26%, transparent);
  color: var(--err-ink); font-size: .93rem; line-height: 1.6;
}
.form-alert::before {
  content: ""; flex: none; width: 8px; height: 8px; margin-top: 8px; border-radius: 50%;
  background: var(--err);
}
.form-alert > span { flex: 1 1 200px; }
.form-alert .link-btn { color: var(--text); min-height: 44px; margin: -12px 0; padding: 0; font-weight: 650; }

/* 링크처럼 보이는 버튼 */
.link-btn {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0; border: 0; background: none;
  color: var(--text-2); font-size: .9rem; font-weight: 550;
  text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--text-2) 35%, transparent); text-underline-offset: 4px;
  transition: color var(--d-1), text-decoration-color var(--d-1);
}
.link-btn:hover { color: var(--text); text-decoration-color: currentColor; }

/* 동의 체크 */
.agree { border: 0; margin: 0; padding: 0; min-width: 0; display: grid; gap: 2px; }
.agree .check { min-height: 44px; align-items: center; color: var(--text-2); font-size: .94rem; cursor: pointer; }
.agree .check input {
  -webkit-appearance: none; appearance: none; flex: none; margin: 0; width: 22px; height: 22px; cursor: pointer;
  border-radius: 7px; border: 1.5px solid var(--line-input); background: rgb(var(--tint-rgb) / .03) center / 13px no-repeat;
  transition: background-color var(--d-2), border-color var(--d-2), box-shadow var(--d-2);
}
.agree .check:hover input:not(:checked) { border-color: rgb(var(--line-rgb) / .62); }
.agree .check input:checked {
  border-color: var(--ether); background-color: var(--ether);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23042019' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'><path d='M5.5 12.5l4.5 4.5 8.5-9.5'/></svg>");
}
.agree .check input:focus-visible { outline: var(--focus-w) solid var(--focus); outline-offset: var(--focus-off); }
.agree .check input[aria-invalid="true"] { border-color: color-mix(in srgb, var(--err) 70%, transparent); }
.agree .check a { color: var(--text); text-decoration: underline; text-decoration-color: rgb(var(--text-rgb) / .35); text-underline-offset: 3px; }
.agree .check a:hover { text-decoration-color: currentColor; }
.agree .field-error { margin-top: 4px; }

/* ==========================================================================
   /login/ 배치
   ========================================================================== */
.auth {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr);
  grid-template-areas: "brand sheet";
  min-height: calc(100vh - var(--header-h));
  min-height: calc(100svh - var(--header-h));
}

/* 오른쪽: 단단한 바닥(폼) */
.auth-sheet {
  grid-area: sheet; position: relative;
  display: flex; justify-content: center; align-items: center;
  padding: clamp(40px, 6vh, 72px) clamp(24px, 5vw, 80px);
  background: linear-gradient(180deg, color-mix(in srgb, var(--panel) 90%, transparent), color-mix(in srgb, var(--bg-2) 86%, transparent));
  border-left: 1px solid var(--line);
}
.auth-col { width: min(100%, 420px); }

/* 모드 전환 */
.auth-switch { display: flex; width: 100%; }
.auth-switch .tab { flex: 1 1 0; height: 44px; font-size: .98rem; }
.auth-switch:not([hidden]) ~ .auth-view { margin-top: 36px; }

.auth-view { animation: auth-in var(--d-3) var(--ease-out); }
@keyframes auth-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.auth-title { font-family: var(--f-display); font-weight: var(--w-display); font-size: clamp(1.9rem, 2.6vw, 2.35rem); line-height: 1.22; letter-spacing: -0.02em; outline: none; }
.auth-sub { margin-top: 10px; color: var(--text-2); font-size: 1rem; line-height: 1.7; max-width: 36em; text-wrap: pretty; }
.auth-title + .auth-form, .auth-sub + .auth-form, .auth-notice + .auth-form { margin-top: 28px; }
.auth-title + .auth-notice, .auth-sub + .auth-notice { margin-top: 20px; }
.auth-back { margin: -14px 0 6px; }
.auth-back .link-btn::before { content: ""; width: 7px; height: 7px; border-left: 1.6px solid currentColor; border-bottom: 1.6px solid currentColor; transform: rotate(45deg); margin: 0 10px 0 2px; }
.auth-back .link-btn { text-decoration: none; }

.field-foot { display: flex; justify-content: flex-end; margin: -8px 0 -14px; }

/* 안내 (에러 아님) */
.auth-notice {
  padding: 12px 14px; border-radius: var(--r-md); font-size: .93rem; line-height: 1.6;
  background: var(--ether-dim); border: 1px solid rgb(var(--ether-rgb) / .22); color: color-mix(in srgb, var(--mint-ink) 40%, var(--text));
}

/* 불러오는 중: 잠깐이면 아무것도 보이지 않게, 길어질 때만 보인다 */
.auth-loading-text {
  display: flex; align-items: center; gap: 12px; color: var(--text-2); font-size: .95rem;
  opacity: 0; animation: auth-appear var(--d-3) ease 500ms forwards;
}
@keyframes auth-appear { to { opacity: 1; } }

/* 메일 확인 화면 */
.mail-addr {
  margin-top: 22px; padding: 14px 16px; border-radius: var(--r-md);
  background: rgb(var(--tint-rgb) / .035); border: 1px solid var(--line-2);
  font-weight: 650; font-size: 1.02rem; overflow-wrap: anywhere; word-break: break-all;
}
.auth-actions { display: grid; gap: 10px; margin-top: 22px; }
.resend-hint { font-size: .84rem; color: var(--text-3); text-align: center; font-variant-numeric: tabular-nums; }
.auth-tips { list-style: none; margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--line); display: grid; gap: 10px; color: var(--text-3); font-size: .88rem; line-height: 1.65; }
.auth-tips li { position: relative; padding-left: 16px; }
.auth-tips li::before { content: ""; position: absolute; left: 2px; top: .72em; width: 5px; height: 5px; border-radius: 50%; background: var(--text-3); opacity: .7; }
.auth-foot { margin-top: 10px; text-align: center; }
.auth-view > .form-alert { margin-top: 18px; }
.auth-form-inline { margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--line); gap: 14px; }

/* 이미 로그인 */
.whoami { display: flex; align-items: center; gap: 14px; margin-top: 22px; padding: 14px 16px; border-radius: var(--r-md); border: 1px solid var(--line-2); background: rgb(var(--tint-rgb) / .03); }
.whoami-text { display: grid; min-width: 0; }
.whoami-text strong { font-size: 1.05rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.whoami-text span { color: var(--text-3); font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 가입 완료: 다음 걸음 */
.next-steps { list-style: none; margin: 26px 0 26px; border-top: 1px solid var(--line); }
.next-steps li { border-bottom: 1px solid var(--line); }
.next-steps a { display: flex; gap: 14px; align-items: flex-start; padding: 16px 4px; border-radius: var(--r-sm); transition: background var(--d-2); }
.next-steps a:hover { background: rgb(var(--tint-rgb) / .03); }
.next-steps a:hover strong { color: var(--ether); }
.ns-icon { flex: none; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--line-2); color: var(--text-2); }
.next-steps li:nth-child(3) .ns-icon { color: var(--xync); border-color: rgb(var(--xync-rgb) / .3); }
.next-steps li:nth-child(1) .ns-icon { color: var(--ether); border-color: rgb(var(--ether-rgb) / .3); }
.ns-text { display: grid; gap: 2px; }
.ns-text strong { font-weight: 680; transition: color var(--d-2); }
.ns-text span { color: var(--text-2); font-size: .9rem; line-height: 1.55; }

.auth-note-box { padding: 14px; border: 1px dashed var(--line-2); border-radius: var(--r-md); color: var(--text-2); margin-top: 28px; }

/* ---------- 왼쪽: 에테르(브랜드) ---------- */
.auth-brand {
  grid-area: brand; position: relative; overflow: hidden;
  display: flex; flex-direction: column; justify-content: center;
  padding: clamp(32px, 6vh, 72px) 0;
}
.auth-art { position: relative; height: clamp(210px, 34vh, 330px); margin-bottom: clamp(24px, 5vh, 52px); }
.auth-band { display: none; }
.auth-brand-text { padding-inline: clamp(32px, 6.4vw, 104px); max-width: 700px; }
.auth-motto { font-family: var(--f-serif); font-style: italic; font-weight: 400; font-size: clamp(2.3rem, 3.4vw, 3.3rem); line-height: 1.02; letter-spacing: -0.02em; color: var(--text); text-wrap: balance; }
.auth-lede { text-wrap: pretty; margin-top: 18px; font-size: 1.02rem; font-weight: 500; letter-spacing: -0.01em; line-height: 1.6; color: var(--text-2); }
.perks { list-style: none; margin-top: 22px; border-top: 1px solid var(--line); max-width: 30em; }
.perks li { padding: 14px 2px; border-bottom: 1px solid var(--line); font-size: 1.06rem; font-weight: 600; letter-spacing: -0.015em; }
.auth-note { margin-top: 16px; font-size: .88rem; color: var(--text-3); }

/* ---------- 두 줄기 계기 ---------- */
.xy-currents { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.xy-currents .track { fill: none; stroke-width: 1; opacity: .16; }
.xy-currents .glow { fill: none; stroke-width: 7; opacity: .32; }
.xy-currents .line { fill: none; stroke-width: 1.9; }
.xy-currents .head { transition: opacity var(--d-2); }
.xy-currents .spark-dot { transition: opacity var(--d-3), r var(--d-3) var(--ease-out); opacity: .3; }
.xy-currents .spark-halo { transition: opacity var(--d-4) var(--ease-out); opacity: 0; }
.xy-currents .spark-ring { opacity: 0; fill: none; stroke: var(--spark); stroke-width: 1.2; }
.xy-currents.is-lit .spark-dot { opacity: 1; }
.xy-currents.is-lit .spark-halo { opacity: 1; }
.xy-currents.is-bloom .spark-ring { animation: auth-bloom 1100ms var(--ease-out) forwards; }
@keyframes auth-bloom { 0% { opacity: .9; r: 4px; } 100% { opacity: 0; r: 46px; } }
.xy-currents.is-small.is-bloom .spark-ring { animation-name: auth-bloom-sm; }
@keyframes auth-bloom-sm { 0% { opacity: .9; r: 3px; } 100% { opacity: 0; r: 26px; } }

/* ---------- 모바일: 폼이 먼저 ---------- */
@media (max-width: 960px) {
  .auth { grid-template-columns: minmax(0, 1fr); grid-template-areas: "sheet" "brand"; min-height: 0; }
  .auth-sheet { border-left: 0; background: none; padding: 12px 16px 48px; align-items: flex-start; }
  .auth-col { width: min(100%, 460px); }
  .auth-band { display: block; position: relative; height: 64px; margin: 4px -16px 18px; }
  .auth-switch:not([hidden]) ~ .auth-view { margin-top: 28px; }
  .auth-art { display: none; }
  .auth-brand { border-top: 1px solid var(--line); padding: 44px 0 16px; }
  .auth-brand-text { padding-inline: 16px; width: min(100% - 0px, 460px + 32px); margin-inline: auto; }
  .auth-motto { font-size: 2.3rem; }
}
@media (max-width: 420px) {
  .auth-title { font-size: 1.85rem; }
}

@media (prefers-reduced-motion: reduce) {
  .auth-view { animation: none; }
  .auth-loading-text { opacity: 1; animation: none; }
}
