/* ============================================================
   GATTAKA — auth pages styling (Pièce 2 design integration)
   Direction: "Carved Parchment Hero"
   Source: mockups/auth-v1.html (extracted + extended for Pièce 2 pages)
   ============================================================ */

:root {
    --ink: #0a0a0e;
    --ink-2: #14121b;
    --gold: #c9a961;
    --gold-bright: #e6c878;
    --gold-deep: #8a6f3a;
    --parchment: #f4ead0;
    --parchment-dim: rgba(244, 234, 208, 0.62);
    --emerald: #4a7a5e;
    --rust: #b1583a;
    --glass: rgba(20, 18, 27, 0.55);
    --glass-strong: rgba(20, 18, 27, 0.78);
    --hairline: rgba(201, 169, 97, 0.22);
    --hairline-strong: rgba(201, 169, 97, 0.55);

    --display: "Cinzel", "Times New Roman", serif;
    --serif: "Fraunces", Georgia, serif;
    --sans: "Outfit", system-ui, sans-serif;

    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-soft: cubic-bezier(0.22, 1, 0.36, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    height: 100%;
    background: var(--ink);
    color: var(--parchment);
    font-family: var(--sans);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* ===== Background video layer ===== */
.bg-stage {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    background: radial-gradient(ellipse at 30% 40%, #1a1828 0%, #0a0a0e 60%, #050507 100%);
}

.bg-stage video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 30%;
    animation: kenburns 38s var(--ease-soft) infinite alternate;
    filter: saturate(0.85) contrast(1.05) brightness(0.78);
    will-change: transform;
    transform: translateZ(0);
    backface-visibility: hidden;
}

@keyframes kenburns {
    0%   { transform: scale(1.04) translate(0, 0); }
    100% { transform: scale(1.14) translate(-1%, -1.5%); }
}

.bg-stage::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 50% 35%, rgba(10, 10, 14, 0.0) 0%, rgba(10, 10, 14, 0.55) 60%, rgba(5, 5, 7, 0.92) 100%),
        linear-gradient(180deg, rgba(10, 10, 14, 0.45) 0%, rgba(10, 10, 14, 0.15) 35%, rgba(10, 10, 14, 0.65) 100%);
    z-index: 1;
    pointer-events: none;
}

.bg-stage::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 70% 70%, rgba(201, 169, 97, 0.06) 0%, transparent 50%);
    z-index: 2;
    pointer-events: none;
    mix-blend-mode: screen;
}

.grain {
    position: fixed;
    inset: 0;
    z-index: 3;
    pointer-events: none;
    opacity: 0.10;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.9 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

.motes {
    position: fixed;
    inset: 0;
    z-index: 4;
    pointer-events: none;
    overflow: hidden;
}
.motes span {
    position: absolute;
    bottom: -10px;
    width: 3px;
    height: 3px;
    background: radial-gradient(circle, rgba(230, 200, 120, 0.9) 0%, rgba(230, 200, 120, 0) 70%);
    border-radius: 50%;
    animation: rise 18s linear infinite;
    opacity: 0;
}
@keyframes rise {
    0%   { transform: translate(0, 0) scale(0.6); opacity: 0; }
    10%  { opacity: 0.9; }
    90%  { opacity: 0.7; }
    100% { transform: translate(var(--dx, 0), -110vh) scale(1.4); opacity: 0; }
}

/* ===== Top brand bar ===== */
.topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 28px 56px;
    pointer-events: none;
    opacity: 0;
    animation: fadeDown 1.2s var(--ease-out) 0.1s forwards;
}
.topbar > * { pointer-events: auto; }

.wordmark {
    font-family: var(--display);
    font-weight: 700;
    letter-spacing: 0.42em;
    font-size: 18px;
    color: var(--parchment);
    text-shadow: 0 2px 20px rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    gap: 14px;
    text-decoration: none;
}
.wordmark::before {
    content: "";
    width: 6px;
    height: 6px;
    background: var(--gold);
    transform: rotate(45deg);
    box-shadow: 0 0 12px rgba(201, 169, 97, 0.8);
}

.topbar nav {
    display: flex;
    gap: 36px;
    font-family: var(--sans);
    font-size: 12px;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    color: var(--parchment-dim);
}
.topbar nav a {
    color: inherit;
    text-decoration: none;
    transition: color 0.4s var(--ease-out);
    position: relative;
}
.topbar nav a:hover { color: var(--gold-bright); }
.topbar nav a::after {
    content: "";
    position: absolute;
    left: 0; right: 0;
    bottom: -6px;
    height: 1px;
    background: var(--gold);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.5s var(--ease-out);
}
.topbar nav a:hover::after { transform: scaleX(1); }

/* ===== Hero copy (left side) — only on home + auth-with-hero pages ===== */
.hero-copy {
    position: fixed;
    z-index: 10;
    left: 110px;
    top: 50%;
    transform: translateY(-50%);
    max-width: 480px;
    pointer-events: none;
    opacity: 0;
    animation: slideRight 1.4s var(--ease-out) 0.5s forwards;
}
.hero-copy .kicker {
    font-family: var(--sans);
    font-size: 11px;
    letter-spacing: 0.5em;
    text-transform: uppercase;
    color: var(--gold);
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 14px;
}
.hero-copy .kicker::before {
    content: "";
    width: 36px;
    height: 1px;
    background: var(--gold);
}
.hero-copy h1 {
    font-family: var(--display);
    font-weight: 600;
    font-size: clamp(40px, 5.2vw, 76px);
    line-height: 0.95;
    letter-spacing: 0.02em;
    color: var(--parchment);
    text-shadow: 0 4px 40px rgba(0, 0, 0, 0.7);
    margin-bottom: 22px;
}
.hero-copy h1 em {
    font-style: italic;
    font-family: var(--serif);
    font-weight: 300;
    font-variation-settings: "SOFT" 100;
    color: var(--gold-bright);
    display: block;
    font-size: 0.7em;
    margin-top: 6px;
    letter-spacing: -0.01em;
}
.hero-copy p {
    font-family: var(--serif);
    font-weight: 300;
    font-size: 17px;
    line-height: 1.65;
    color: var(--parchment-dim);
    max-width: 380px;
}

/* ===== Auth card (right side, or centered for non-hero pages) ===== */
.card-stage {
    position: fixed;
    z-index: 11;
    right: 56px;
    top: 50%;
    transform: translateY(-50%);
    width: 440px;
    opacity: 0;
    animation: slideLeft 1.4s var(--ease-out) 0.7s forwards;
}

/* Wide card variant — for select-character with character grid */
.card-stage.card-stage-wide {
    width: 600px;
}

/* Centered card variant — for pages without hero copy */
.card-stage.card-stage-centered {
    right: auto;
    left: 50%;
    transform: translate(-50%, -50%);
    animation: slideUp 1.4s var(--ease-out) 0.5s forwards;
}

.card {
    position: relative;
    background: var(--glass-strong);
    backdrop-filter: blur(12px) saturate(1.15);
    -webkit-backdrop-filter: blur(12px) saturate(1.15);
    border: 1px solid var(--hairline);
    padding: 44px 40px 38px;
    box-shadow:
        0 1px 0 rgba(244, 234, 208, 0.05) inset,
        0 30px 80px -20px rgba(0, 0, 0, 0.7),
        0 0 0 1px rgba(0, 0, 0, 0.5);
}

/* Ornate corners — small gold brackets */
.card::before,
.card::after {
    content: "";
    position: absolute;
    width: 22px;
    height: 22px;
    border: 1.5px solid var(--gold);
    pointer-events: none;
}
.card::before {
    top: -1px; left: -1px;
    border-right: none;
    border-bottom: none;
}
.card::after {
    bottom: -1px; right: -1px;
    border-left: none;
    border-top: none;
}
.card-corners {
    position: absolute;
    inset: 0;
    pointer-events: none;
}
.card-corners::before,
.card-corners::after {
    content: "";
    position: absolute;
    width: 22px;
    height: 22px;
    border: 1.5px solid var(--gold);
}
.card-corners::before {
    top: -1px; right: -1px;
    border-left: none;
    border-bottom: none;
}
.card-corners::after {
    bottom: -1px; left: -1px;
    border-right: none;
    border-top: none;
}

/* Card header */
.card-header {
    text-align: center;
    margin-bottom: 32px;
}
.card-header .seal {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    margin-bottom: 18px;
    position: relative;
}
.card-header .seal svg {
    width: 100%;
    height: 100%;
    fill: none;
    stroke: var(--gold);
    stroke-width: 1.4;
}
.card-header .seal::after {
    content: "";
    position: absolute;
    inset: 50%;
    width: 5px; height: 5px;
    margin: -2.5px;
    background: var(--gold);
    transform: rotate(45deg);
    box-shadow: 0 0 14px var(--gold);
}
.card-header h2 {
    font-family: var(--display);
    font-weight: 600;
    font-size: 22px;
    letter-spacing: 0.32em;
    color: var(--parchment);
    text-transform: uppercase;
    margin-bottom: 8px;
}
.card-header p {
    font-family: var(--serif);
    font-weight: 300;
    font-style: italic;
    font-size: 13px;
    color: var(--parchment-dim);
    letter-spacing: 0.02em;
}

/* ===== Tabs (login/signup tabbed card) ===== */
.tabs {
    display: flex;
    margin-bottom: 32px;
    border-top: 1px solid var(--hairline);
    border-bottom: 1px solid var(--hairline);
    position: relative;
}
.tab {
    flex: 1;
    background: none;
    border: none;
    color: var(--parchment-dim);
    font-family: var(--sans);
    font-size: 11px;
    letter-spacing: 0.32em;
    text-transform: uppercase;
    padding: 16px 0;
    cursor: pointer;
    transition: color 0.4s var(--ease-out);
    position: relative;
}
.tab.is-active { color: var(--gold-bright); }
.tab:hover:not(.is-active) { color: var(--parchment); }

.tab-indicator {
    position: absolute;
    bottom: -1px;
    height: 2px;
    background: var(--gold);
    transition: left 0.5s var(--ease-out), width 0.5s var(--ease-out);
    box-shadow: 0 0 12px rgba(201, 169, 97, 0.6);
    pointer-events: none;
}

/* Tabbed-card forms — explicitly hidden until is-active.
   Plain <form> on other pages keeps the simple fadeIn behaviour below. */
.auth-form {
    display: none;
    animation: fadeIn 0.4s var(--ease-out);
}
.auth-form.is-active { display: block; }

/* Forms */
form { animation: fadeIn 0.5s var(--ease-out); }

.field {
    margin-bottom: 18px;
    position: relative;
}
.field label {
    display: block;
    font-family: var(--sans);
    font-size: 10px;
    letter-spacing: 0.32em;
    text-transform: uppercase;
    color: var(--parchment-dim);
    margin-bottom: 8px;
    transition: color 0.3s var(--ease-out);
}
.field input {
    width: 100%;
    background: rgba(244, 234, 208, 0.04);
    border: 1px solid var(--hairline);
    color: var(--parchment);
    font-family: var(--sans);
    font-size: 15px;
    padding: 14px 16px;
    transition: all 0.3s var(--ease-out);
    letter-spacing: 0.01em;
}
.field input::placeholder {
    color: rgba(244, 234, 208, 0.25);
    font-style: italic;
    font-family: var(--serif);
    font-weight: 300;
}
.field input:hover {
    border-color: rgba(201, 169, 97, 0.4);
    background: rgba(244, 234, 208, 0.06);
}
.field input:focus {
    outline: none;
    border-color: var(--gold);
    background: rgba(244, 234, 208, 0.08);
    box-shadow: 0 0 0 3px rgba(201, 169, 97, 0.12), 0 0 24px rgba(201, 169, 97, 0.18);
}
.field:focus-within label { color: var(--gold-bright); }

.field.invite input {
    font-family: var(--display);
    font-size: 18px;
    letter-spacing: 0.4em;
    text-align: center;
    text-transform: uppercase;
}

/* Submit / primary button */
.submit, .btn-primary {
    width: 100%;
    margin-top: 12px;
    padding: 16px;
    background: linear-gradient(180deg, var(--gold-bright) 0%, var(--gold) 50%, var(--gold-deep) 100%);
    border: 1px solid var(--gold-deep);
    color: var(--ink);
    font-family: var(--display);
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 0.42em;
    text-transform: uppercase;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all 0.3s var(--ease-out);
    box-shadow:
        0 1px 0 rgba(255, 235, 180, 0.4) inset,
        0 -1px 0 rgba(0, 0, 0, 0.2) inset,
        0 8px 24px -8px rgba(201, 169, 97, 0.5);
    display: inline-block;
    text-align: center;
    text-decoration: none;
}
.submit:hover, .btn-primary:hover {
    transform: translateY(-1px);
    box-shadow:
        0 1px 0 rgba(255, 235, 180, 0.5) inset,
        0 -1px 0 rgba(0, 0, 0, 0.2) inset,
        0 12px 32px -8px rgba(201, 169, 97, 0.7);
}
.submit:active, .btn-primary:active { transform: translateY(0); }
.submit::before, .btn-primary::before {
    content: "";
    position: absolute;
    top: 0; left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    transition: left 0.7s var(--ease-out);
}
.submit:hover::before, .btn-primary:hover::before { left: 100%; }

/* Secondary button — outline with gold */
.btn-secondary {
    display: inline-block;
    padding: 14px 22px;
    background: transparent;
    border: 1px solid var(--hairline);
    color: var(--parchment);
    font-family: var(--sans);
    font-size: 11px;
    letter-spacing: 0.32em;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.3s var(--ease-out);
    text-decoration: none;
    text-align: center;
}
.btn-secondary:hover {
    border-color: var(--gold);
    color: var(--gold-bright);
}

/* Helper text */
.helper, .auth-help {
    font-family: var(--serif);
    font-size: 12px;
    font-style: italic;
    color: var(--parchment-dim);
    margin-top: 8px;
    line-height: 1.5;
}
.helper strong, .auth-help strong {
    color: var(--gold);
    font-weight: 500;
    font-style: normal;
    font-family: var(--sans);
    letter-spacing: 0.02em;
}

.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

/* Error / alert blocks */
.auth-error {
    background: rgba(177, 88, 58, 0.12);
    border: 1px solid rgba(177, 88, 58, 0.45);
    color: rgba(244, 234, 208, 0.92);
    padding: 12px 14px;
    margin-bottom: 18px;
    font-family: var(--sans);
    font-size: 13px;
    line-height: 1.5;
}
.auth-error a {
    color: var(--gold-bright);
    text-decoration: underline;
}

/* Success block */
.auth-success {
    background: rgba(74, 122, 94, 0.12);
    border: 1px solid rgba(74, 122, 94, 0.45);
    color: rgba(244, 234, 208, 0.92);
    padding: 12px 14px;
    margin-bottom: 18px;
    font-family: var(--sans);
    font-size: 13px;
    line-height: 1.5;
}

/* Card footer */
.card-footer {
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid var(--hairline);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-family: var(--sans);
    font-size: 11px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--parchment-dim);
    gap: 12px;
}
.card-footer a {
    color: var(--gold);
    text-decoration: none;
    transition: color 0.3s var(--ease-out);
}
.card-footer a:hover { color: var(--gold-bright); }

.card-footer.card-footer-stack {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    text-align: center;
}

/* ===== Bottom bar ===== */
.bottombar {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 22px 56px;
    font-family: var(--sans);
    font-size: 10px;
    letter-spacing: 0.32em;
    text-transform: uppercase;
    color: rgba(244, 234, 208, 0.4);
    pointer-events: none;
    opacity: 0;
    animation: fadeUp 1.2s var(--ease-out) 1.0s forwards;
}
.bottombar > * { pointer-events: auto; }
.bottombar .build {
    display: flex;
    align-items: center;
    gap: 10px;
}
.bottombar .build::before {
    content: "";
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--emerald);
    box-shadow: 0 0 8px var(--emerald);
    animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* Decorative side mark */
.side-mark {
    position: fixed;
    left: 56px;
    bottom: 0;
    top: 0;
    width: 1px;
    z-index: 5;
    background: linear-gradient(180deg, transparent 0%, var(--hairline-strong) 30%, var(--hairline-strong) 70%, transparent 100%);
    pointer-events: none;
}

/* ===== Character grid (select-character page) ===== */
.character-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}
.character-card {
    background: rgba(244, 234, 208, 0.04);
    border: 1px solid var(--hairline);
    padding: 18px 14px;
    cursor: pointer;
    transition: all 0.3s var(--ease-out);
    text-align: center;
    position: relative;
    overflow: hidden;
}
.character-card:hover {
    border-color: var(--gold);
    background: rgba(244, 234, 208, 0.08);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px -8px rgba(201, 169, 97, 0.4);
}
.character-card:active { transform: translateY(0); }
.character-card .character-name {
    font-family: var(--display);
    font-weight: 600;
    font-size: 16px;
    letter-spacing: 0.06em;
    color: var(--parchment);
    margin-bottom: 4px;
}
.character-card .character-meta {
    font-family: var(--serif);
    font-size: 12px;
    font-style: italic;
    color: var(--parchment-dim);
}
.character-card-empty {
    cursor: default;
    color: var(--parchment-dim);
    font-style: italic;
}
.character-card-empty:hover {
    transform: none;
    border-color: var(--hairline);
    background: rgba(244, 234, 208, 0.04);
    box-shadow: none;
}

.auth-logout {
    margin-top: 8px;
    text-align: center;
}
.auth-logout button {
    background: none;
    border: none;
    color: var(--parchment-dim);
    font-family: var(--sans);
    font-size: 11px;
    letter-spacing: 0.32em;
    text-transform: uppercase;
    cursor: pointer;
    transition: color 0.3s var(--ease-out);
}
.auth-logout button:hover { color: var(--gold-bright); }

/* ===== Reveal animations ===== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeDown {
    from { opacity: 0; transform: translateY(-12px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideRight {
    from { opacity: 0; transform: translateY(-50%) translateX(-30px); }
    to   { opacity: 1; transform: translateY(-50%) translateX(0); }
}
@keyframes slideLeft {
    from { opacity: 0; transform: translateY(-50%) translateX(30px); }
    to   { opacity: 1; transform: translateY(-50%) translateX(0); }
}
@keyframes slideUp {
    from { opacity: 0; transform: translate(-50%, -45%); }
    to   { opacity: 1; transform: translate(-50%, -50%); }
}

/* ===== Responsive ===== */
@media (max-width: 980px) {
    .hero-copy {
        position: static;
        transform: none;
        padding: 100px 32px 0;
        max-width: none;
        text-align: center;
    }
    .hero-copy .kicker { justify-content: center; }
    .card-stage, .card-stage-wide, .card-stage-centered {
        position: static;
        transform: none;
        width: auto;
        max-width: 460px;
        margin: 32px auto 80px;
        padding: 0 24px;
        animation: fadeIn 0.6s var(--ease-out) forwards;
    }
    .topbar { padding: 18px 24px; }
    .topbar nav { gap: 18px; font-size: 10px; }
    .bottombar { padding: 16px 24px; flex-direction: column; gap: 8px; text-align: center; }
    .side-mark { display: none; }
    body, html { overflow-y: auto; overflow-x: hidden; }
    .bg-stage { position: fixed; }
}

@media (max-width: 520px) {
    .card { padding: 32px 24px 28px; }
    .field-row { grid-template-columns: 1fr; }
}
