/*
 * auth-page.css
 * Aurora atmospheric editorial — login / register / forgot-password / reset-password.
 *
 * 設計コンセプト: 夜のニュースルームの窓辺に立つような、静かで品のある光と影。
 *  - 背景: 深い夜空 + ブランドの purple / cyan が左上 / 右下から差し込む radial mesh
 *  - カード: 半透明ガラス + ブランドカラーのヘアライン gradient border
 *  - タイポ: ブランドグラデを title にクリッピング、weight コントラストを強く
 *  - モーション: 入場時の staggered rise、ボタンの shine sweep
 */

/* 背景の base color と radial mesh は styles.css の :root + body::before を
 * そのまま継承する（viewer / auth / profile で完全に同一の色味を共有）。
 * auth-page.css は ガラスカード・タイポ・フォーム・ボタン等の局所スタイルに専念。 */
:root {
    --auth-glass-bg: rgba(18, 18, 36, 0.55);
    --auth-glass-border: rgba(255, 255, 255, 0.08);
    --auth-text-primary: #fff;
    --auth-text-soft: rgba(255, 255, 255, 0.72);
    --auth-text-muted: rgba(255, 255, 255, 0.45);
    --auth-text-hint: rgba(255, 255, 255, 0.32);
    --auth-input-bg: rgba(255, 255, 255, 0.04);
    --auth-input-bg-hover: rgba(255, 255, 255, 0.07);
    --auth-input-border: rgba(255, 255, 255, 0.10);
    --auth-link: #b39bff;
    --auth-link-hover: #d2c2ff;
    --auth-success: #4ade80;
    --auth-danger: #f87171;
    --gradient-brand: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
}

.auth-container {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(1rem, 4vw, 3rem);
    position: relative;
}

/* ── カード ─────────────────────────────────────── */
.auth-card {
    position: relative;
    width: 100%;
    max-width: 460px;
    padding: clamp(2rem, 5vw, 3rem);
    background: var(--auth-glass-bg);
    backdrop-filter: blur(24px) saturate(140%);
    -webkit-backdrop-filter: blur(24px) saturate(140%);
    border: 1px solid var(--auth-glass-border);
    border-radius: 24px;
    box-shadow:
        0 24px 60px rgba(0, 0, 0, 0.55),
        0 1px 0 rgba(255, 255, 255, 0.05) inset,
        0 0 0 1px rgba(255, 255, 255, 0.02) inset;
    animation: auth-rise 700ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

/* ヘアライン gradient border (1px) */
.auth-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(135deg, rgba(167, 139, 250, 0.45) 0%, rgba(255, 255, 255, 0) 30%, rgba(34, 211, 238, 0.35) 100%);
    -webkit-mask:
        linear-gradient(#000 0 0) content-box,
        linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
            mask-composite: exclude;
    pointer-events: none;
}

/* カード内子要素の staggered fade-in */
.auth-card > * { animation: auth-rise 600ms cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.auth-card > *:nth-child(1) { animation-delay: 100ms; }
.auth-card > *:nth-child(2) { animation-delay: 180ms; }
.auth-card > *:nth-child(3) { animation-delay: 260ms; }
.auth-card > *:nth-child(4) { animation-delay: 340ms; }
.auth-card > *:nth-child(5) { animation-delay: 420ms; }
.auth-card > *:nth-child(6) { animation-delay: 500ms; }
.auth-card > *:nth-child(7) { animation-delay: 580ms; }

@keyframes auth-rise {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    /* 装飾的なモーションを全面停止。フォーカス遷移など必須のものは
       :focus-visible のスタイル変化として残し、transition は無効化する。 */
    .auth-card,
    .auth-card > *,
    .btn-login,
    .btn-register,
    .btn-submit,
    .password-toggle,
    .form-group input,
    .form-group select,
    .forgot-password,
    .back-home,
    .auth-lang-toggle {
        animation: none !important;
        transition: none !important;
    }
    .btn-login::after,
    .btn-register::after,
    .btn-submit::after { display: none; }
}

/* ── ヘッダー ─────────────────────────────────── */
.auth-header {
    text-align: center;
    margin-bottom: 1.75rem;
}

.auth-header h1 {
    color: var(--auth-text-primary);
    font-size: clamp(1.85rem, 4vw, 2.25rem);
    font-weight: 900;
    letter-spacing: -0.03em;
    line-height: 1.1;
    margin: 0 0 0.6rem;
}

.auth-header h1.gradient-text {
    background: var(--gradient-brand);
    -webkit-background-clip: text;
            background-clip: text;
    -webkit-text-fill-color: transparent;
            color: transparent;
}

.auth-header p {
    color: var(--auth-text-soft);
    font-size: 0.92rem;
    line-height: 1.6;
    margin: 0;
}

/* ── フォーム ─────────────────────────────────── */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    color: var(--auth-text-soft);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-bottom: 0.5rem;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.85rem 1rem;
    background: var(--auth-input-bg);
    border: 1px solid var(--auth-input-border);
    border-radius: 12px;
    color: var(--auth-text-primary);
    font-family: inherit;
    font-size: 1rem;
    transition: background-color 200ms ease, border-color 200ms ease, box-shadow 200ms ease;
}

.form-group input:hover,
.form-group select:hover {
    background: var(--auth-input-bg-hover);
    border-color: rgba(255, 255, 255, 0.18);
}

.form-group input:focus-visible,
.form-group select:focus-visible {
    outline: none;
    background: var(--auth-input-bg-hover);
    border-color: rgba(167, 139, 250, 0.7);
    box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.18);
}

.form-group input::placeholder {
    color: var(--auth-text-hint);
}

.form-group select { cursor: pointer; }
.form-group select option { background: #16162e; color: #fff; }

.form-group small {
    display: block;
    color: var(--auth-text-muted);
    font-size: 0.78rem;
    margin-top: 0.4rem;
}

/* パスワード visibility toggle: input の右端に絶対配置するアイコンボタン。
   top/bottom 両方を 6px に固定して垂直中央を確保（transform を使わない方式） */
.password-field {
    position: relative;
    display: block;
}
.password-field input {
    width: 100%;
    padding-right: 2.75rem;
}
.password-toggle {
    position: absolute;
    right: 6px;
    top: 6px;
    bottom: 6px;
    width: 36px;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 0;
    background: transparent;
    color: var(--auth-text-muted);
    border-radius: 8px;
    cursor: pointer;
    z-index: 2;
    line-height: 0;
    transition: color 160ms ease, background-color 160ms ease;
}
.password-toggle:hover {
    color: var(--auth-text-primary);
    background: rgba(255, 255, 255, 0.06);
}
.password-toggle:focus-visible {
    outline: 2px solid rgba(34, 211, 238, 0.7);
    outline-offset: 2px;
}
.password-toggle > svg { width: 18px; height: 18px; flex-shrink: 0; pointer-events: none; }
.password-toggle .icon-eye-off { display: none; }
.password-toggle.is-visible .icon-eye     { display: none; }
.password-toggle.is-visible .icon-eye-off { display: block; }

/* ── パスワード強度バー (register) ─────────────── */
.password-strength { margin-top: 0.5rem; }
.password-strength-bar {
    height: 4px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 0.3rem;
}
.password-strength-fill {
    height: 100%;
    width: 0%;
    transition: width 240ms ease, background-color 240ms ease;
    border-radius: 999px;
}
.password-strength-fill.weak   { width: 33%;  background: var(--auth-danger); }
.password-strength-fill.medium { width: 66%;  background: #fbbf24; }
.password-strength-fill.strong { width: 100%; background: var(--auth-success); }
.password-strength-text {
    font-size: 0.78rem;
    color: var(--auth-text-muted);
}
.password-strength-text.invalid { color: var(--auth-danger); font-weight: 600; }

/* form-hint: 入力補足／バリデーション */
.form-hint {
    display: block;
    margin-top: 0.4rem;
    font-size: 0.78rem;
    color: var(--auth-text-muted);
}
.form-hint.invalid { color: var(--auth-danger); font-weight: 600; }
.form-hint.valid   { color: var(--auth-success); }

/* ── ログイン専用: form options ─────────────── */
.form-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    font-size: 0.86rem;
}

.checkbox-label {
    display: inline-flex;
    align-items: center;
    color: var(--auth-text-soft);
    cursor: pointer;
    user-select: none;
}
.checkbox-label input {
    margin-right: 0.5rem;
    accent-color: #a78bfa;
    cursor: pointer;
}

.checkbox-christian {
    background: rgba(124, 58, 237, 0.08);
    border: 1px solid rgba(124, 58, 237, 0.28);
    padding: 1rem;
    border-radius: 12px;
    margin-bottom: 1.5rem;
}
.checkbox-christian label {
    color: var(--auth-text-primary);
    font-weight: 500;
}
.checkbox-christian input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-right: 0.75rem;
    accent-color: #a78bfa;
}

.forgot-password {
    color: var(--auth-link);
    text-decoration: none;
    transition: color 200ms ease;
}
.forgot-password:hover { color: var(--auth-link-hover); }
.forgot-password:focus-visible {
    outline: 2px solid var(--auth-link-hover);
    outline-offset: 3px;
    border-radius: 4px;
}

/* ── ボタン: primary submit (login / register / forgot / reset) ───── */
.btn-login,
.btn-register,
.btn-submit {
    position: relative;
    overflow: hidden;
    width: 100%;
    padding: 1rem 1.25rem;
    background: var(--gradient-brand);
    background-size: 180% 180%;
    background-position: 0% 50%;
    border: none;
    border-radius: 12px;
    color: #fff;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition:
        transform 200ms cubic-bezier(0.2, 0.8, 0.2, 1),
        box-shadow 240ms ease,
        background-position 600ms ease;
    margin-bottom: 1rem;
    box-shadow: 0 8px 24px rgba(118, 75, 162, 0.32);
}

.btn-login::after,
.btn-register::after,
.btn-submit::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, 0.28) 50%, transparent 70%);
    transform: translateX(-110%);
    transition: transform 600ms ease;
    pointer-events: none;
}

.btn-login:hover,
.btn-register:hover,
.btn-submit:hover {
    transform: translateY(-2px);
    background-position: 100% 50%;
    box-shadow: 0 14px 32px rgba(118, 75, 162, 0.48);
}
.btn-login:hover::after,
.btn-register:hover::after,
.btn-submit:hover::after {
    transform: translateX(110%);
}

.btn-login:active,
.btn-register:active,
.btn-submit:active {
    transform: translateY(0) scale(0.985);
}

.btn-login:disabled,
.btn-register:disabled,
.btn-submit:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    /* 色覚特性ユーザー向けに opacity 以外の視覚指標を併用 (WCAG 1.4.1)。
       45 度ストライプで disabled パターンを上塗りする。 */
    background-image: repeating-linear-gradient(
        45deg,
        rgba(255, 255, 255, 0.08) 0,
        rgba(255, 255, 255, 0.08) 8px,
        transparent 8px,
        transparent 16px
    );
}

.btn-login:focus-visible,
.btn-register:focus-visible,
.btn-submit:focus-visible {
    outline: 2px solid rgba(34, 211, 238, 0.85);
    outline-offset: 3px;
}

/* ── divider ─────────────────────────────────── */
.divider {
    text-align: center;
    margin: 1.75rem 0 1.25rem;
    position: relative;
}
.divider::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    width: 100%;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.12), transparent);
}
.divider span {
    position: relative;
    background: var(--auth-glass-bg);
    padding: 0 0.85rem;
    color: var(--auth-text-muted);
    font-size: 0.74rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

/* ── Google ボタン ─────────────────────────── */
.btn-google {
    width: 100%;
    padding: 0.9rem 1rem;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 12px;
    color: #1f2937;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 200ms ease, box-shadow 240ms ease, background-color 200ms ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
}
.btn-google:hover {
    transform: translateY(-1px);
    background: #fff;
    box-shadow: 0 10px 24px rgba(255, 255, 255, 0.18);
}

/* ── フッター ─────────────────────────────── */
.auth-footer {
    text-align: center;
    margin-top: 1.75rem;
    color: var(--auth-text-soft);
    font-size: 0.88rem;
}

.auth-footer a {
    color: var(--auth-link);
    text-decoration: none;
    font-weight: 600;
    transition: color 200ms ease;
}
.auth-footer a:hover { color: var(--auth-link-hover); }

/* ── メッセージ ─────────────────────────── */
.error-message {
    background: rgba(248, 113, 113, 0.12);
    border: 1px solid rgba(248, 113, 113, 0.4);
    color: #fca5a5;
    padding: 0.85rem 1rem;
    border-radius: 12px;
    margin-bottom: 1.25rem;
    font-size: 0.88rem;
    display: none;
}
.error-message.show { display: block; }
.error-message.success {
    background: rgba(74, 222, 128, 0.12);
    border-color: rgba(74, 222, 128, 0.4);
    color: #86efac;
}

.message {
    padding: 0.85rem 1rem;
    border-radius: 12px;
    margin-bottom: 1.25rem;
    font-size: 0.88rem;
    display: none;
}
.message.error {
    background: rgba(248, 113, 113, 0.12);
    border: 1px solid rgba(248, 113, 113, 0.4);
    color: #fca5a5;
}
.message.success {
    background: rgba(74, 222, 128, 0.12);
    border: 1px solid rgba(74, 222, 128, 0.4);
    color: #86efac;
}
.message.show { display: block; }

/* ── forgot-password / reset-password アイコンサークル ─────── */
.icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1.25rem;
    background: var(--gradient-brand);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 12px 30px rgba(118, 75, 162, 0.4);
}
.icon svg {
    width: 30px;
    height: 30px;
    stroke: #fff;
}

/* ── 利用規約 ─────────────────────────── */
.terms {
    font-size: 0.82rem;
    color: var(--auth-text-muted);
    text-align: center;
    margin-top: 1rem;
    line-height: 1.6;
}
.terms a {
    color: var(--auth-link);
    text-decoration: none;
}
.terms a:hover { text-decoration: underline; }

/* ── ホームへ戻るリンク ─────────────────────── */
.back-home {
    position: absolute;
    top: clamp(1rem, 3vw, 2rem);
    left: clamp(1rem, 3vw, 2rem);
    z-index: 2;
    color: var(--auth-text-muted);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.88rem;
    padding: 0.5rem 0.85rem;
    border-radius: 999px;
    transition: color 200ms ease, background-color 200ms ease;
}
.back-home:hover {
    color: var(--auth-text-primary);
    background: rgba(255, 255, 255, 0.05);
}
.back-home:focus-visible {
    color: var(--auth-text-primary);
    background: rgba(255, 255, 255, 0.05);
    outline: 2px solid rgba(167, 139, 250, 0.7);
    outline-offset: 2px;
}

/* auth ページ右上の言語切替トグル */
.auth-lang-toggle {
    position: absolute;
    top: clamp(1rem, 3vw, 2rem);
    right: clamp(1rem, 3vw, 2rem);
    z-index: 2;
}

/* sr-only */
.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ── レスポンシブ ─────────────────────────── */
@media (max-width: 480px) {
    .auth-card { padding: 1.75rem 1.25rem; border-radius: 20px; }
    .brand-mark { font-size: 1.3rem; margin-bottom: 1.2rem; }
    .auth-header h1 { font-size: 1.7rem; }
    .form-options { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
}

/* trial-overlay は styles.css に集約（TOP / 認証ページ共用のため）。
   詳細は frontend/public/styles.css の「試験運用中オーバーレイ」セクションを参照。 */
