@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;500;600;700&family=Lora:ital,wght@0,400;0,500;0,600;1,400&display=swap');

/* ==========================================================================
   VAELLUM -- the grimoire gate (login / register)
   --------------------------------------------------------------------------
   The book, opened: a dark ink-and-gold cover on the left holding the seal,
   and the parchment page on the right holding the form. Same cover-to-page
   move as the landing page's night-into-parchment fold, so arriving here from
   the marketing site is one continuous world.

   Two panels, because it solves the real constraints at once: no left-edge
   furniture to crowd the form, room for a seal that reads at a glance, and a
   card short enough to sit inside a laptop viewport without scrolling.

   Loaded AFTER style.css, which owns the global tokens for the rest of the
   game.
   ========================================================================== */

:root {
    --parchment-0: #fbf6ec;
    --parchment-1: #f3ead9;
    --parchment-2: #e7d9c0;
    --parchment-3: #d6c3a3;

    --ink-900: #2a2118;
    --ink-700: #4a3c2c;
    --ink-500: #6b5a45;
    --ink-400: #8b7d6b;

    --gold: #d4af37;
    --gold-bright: #f0cd63;
    --gold-deep: #9a7b1e;

    --moss: #4f8a5b;
    --ember: #b5442f;

    /* Text-safe variants. --ink-400 (3.35:1) and --gold-deep (3.36:1) fall
       below the 4.5:1 WCAG AA floor on parchment, so they stay for decorative
       fills only. Anything the user must read uses these. */
    --ink-text: #6b5a45;   /* 5.54:1 on parchment */
    --gold-text: #7c6318;  /* 4.81:1 on parchment */

    /* Cover */
    --cover-1: #241c14;
    --cover-2: #120d09;

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

/* ------------------------------------------------------------- the page --- */

body.auth-page {
    margin: 0;
    min-height: 100vh;
    font-family: 'Lora', Georgia, 'Times New Roman', serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--ink-900);
    -webkit-font-smoothing: antialiased;

    /* The game's night plate, pushed far back so the card is unambiguously
       the brightest thing on screen. */
    background:
        radial-gradient(ellipse 60% 50% at 50% 45%, rgba(212, 175, 55, 0.12), transparent 70%),
        linear-gradient(rgba(8, 12, 24, 0.92), rgba(6, 9, 18, 0.96)),
        url('../images/backgrounds/BG.jpg') no-repeat center center fixed;
    background-size: cover, cover, cover;
    background-attachment: fixed;
}

/* Fine grain so the large dark field never reads as flat plastic. */
body.auth-page::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    opacity: 0.2;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
}

/* place-items centres on BOTH axes. The previous stage only centred
   horizontally, which left the card pinned to the top with dead space
   beneath it -- the reason the form read as off-centre. */
.auth-stage {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    min-height: 100svh;
    display: grid;
    place-items: center;
    padding: clamp(14px, 2.4vh, 28px) 20px;
}
/* ------------------------------------------------------------ the book --- */

.auth-book {
    display: grid;
    grid-template-columns: clamp(240px, 30%, 320px) minmax(0, 1fr);
    width: min(100%, 900px);

    /* Safety valve for genuinely short viewports: the card scrolls inside
       itself rather than pushing the page and stranding the submit button. */
    max-height: calc(100svh - clamp(28px, 4.8vh, 56px));
    overflow: hidden;

    border-radius: 14px;
    background: linear-gradient(160deg, var(--parchment-1) 0%, #f7eeda 45%, var(--parchment-2) 100%);
    box-shadow:
        0 0 0 1px rgba(74, 60, 44, 0.18),
        0 0 0 5px var(--parchment-2),
        0 0 0 6px rgba(154, 123, 30, 0.3),
        0 30px 70px rgba(0, 0, 0, 0.55);
}

/* ---- cover: ink, leather, gold foil ---- */

.auth-cover {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 30px 24px;
    overflow: hidden;
    border-radius: 14px 0 0 14px;
    background:
        radial-gradient(ellipse 90% 45% at 50% 30%, rgba(212, 175, 55, 0.22), transparent 70%),
        linear-gradient(165deg, #2f2519 0%, var(--cover-1) 48%, var(--cover-2) 100%);
    box-shadow: inset -1px 0 0 rgba(212, 175, 55, 0.32);
}

/* Corner flourishes, gilt on the cover. */
.auth-cover::before,
.auth-cover::after {
    content: "\2756";
    position: absolute;
    font-size: 15px;
    color: var(--gold);
    opacity: 0.5;
}

.auth-cover::before { top: 14px; left: 16px; }
.auth-cover::after { bottom: 14px; right: 16px; }

/* The seal. Large, because it is the one thing that has to read instantly. */
.auth-seal {
    display: block;
    width: auto;
    height: clamp(84px, 12vh, 124px);
    max-width: 100%;
    /* Depth only. A wide colour glow re-uses the seal's own silhouette, and
       the logo's soft edges smear that glow into a haze behind the art. */
    filter: drop-shadow(0 4px 14px rgba(0, 0, 0, 0.62));
}

.auth-cover-kicker {
    margin: 6px 0 0;
    text-align: center;
    font-family: 'Cinzel', Georgia, serif;
    font-size: 0.66rem;
    font-weight: 600;
    letter-spacing: 0.19em;
    text-transform: uppercase;
    text-wrap: balance;
    color: var(--gold-bright);
    opacity: 0.92;
}

.auth-cover-sub {
    margin: 8px 0 0;
    text-align: center;
    font-style: italic;
    font-size: 0.82rem;
    color: rgba(240, 205, 99, 0.66);
}
/* ---- page: parchment, where the form lives ---- */

.auth-sheet {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 30px 38px;
    min-width: 0;
    /* If the content genuinely outruns the viewport, scroll the page only. */
    overflow-y: auto;
    overscroll-behavior: contain;
}

.auth-title {
    margin: 0 0 4px;
    text-align: center;
    font-family: 'Cinzel', Georgia, serif;
    font-size: clamp(1.4rem, 2.5vh, 1.72rem);
    font-weight: 700;
    letter-spacing: 0.01em;
    color: var(--ink-900);
}

.auth-rule {
    height: 1px;
    margin: 0 auto 14px;
    width: 70%;
    background: linear-gradient(90deg, transparent, var(--gold) 24%, var(--gold) 76%, transparent);
    opacity: 0.8;
}

.auth-lede {
    margin: 0 0 16px;
    text-align: center;
    font-style: italic;
    font-size: 0.9rem;
    color: var(--ink-500);
}

/* -------------------------------------------------------------- errors --- */

.auth-error {
    display: flex;
    gap: 9px;
    align-items: flex-start;
    margin: 0 0 16px;
    padding: 11px 13px;
    border-radius: 4px;
    border: 1px solid rgba(181, 68, 47, 0.4);
    border-left: 3px solid var(--ember);
    background: rgba(181, 68, 47, 0.09);
    font-size: 0.86rem;
    line-height: 1.45;
    color: #7d2f1f;
}

/* -------------------------------------------------------------- fields --- */

.auth-field { margin: 0 0 13px; }

.auth-field > label {
    display: block;
    margin-bottom: 5px;
    font-family: 'Cinzel', Georgia, serif;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink-700);
}

.auth-control {
    position: relative;
    display: flex;
    align-items: center;
}

.auth-input {
    width: 100%;
    padding: 10px 13px;
    font-family: inherit;
    font-size: 1rem;
    color: var(--ink-900);
    background: rgba(255, 255, 255, 0.62);
    border: 1px solid var(--parchment-3);
    border-radius: 4px;
    box-shadow: inset 0 1px 3px rgba(74, 60, 44, 0.11);
    transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
}

.auth-input::placeholder { color: rgba(107, 90, 69, 0.5); }
.auth-input:hover:not(:focus) { border-color: var(--gold-deep); }

.auth-input:focus {
    outline: none;
    background: #fff;
    border-color: var(--gold);
    box-shadow: inset 0 1px 3px rgba(74, 60, 44, 0.08), 0 0 0 3px rgba(212, 175, 55, 0.3);
}

.auth-input[aria-invalid='true'] {
    border-color: rgba(181, 68, 47, 0.65);
    box-shadow: inset 0 1px 3px rgba(74, 60, 44, 0.11), 0 0 0 3px rgba(181, 68, 47, 0.14);
}

/* Room for the status tick on the right. */
.auth-control--checked .auth-input { padding-right: 40px; }

.auth-status-icon {
    position: absolute;
    right: 12px;
    width: 16px;
    height: 16px;
    display: grid;
    place-items: center;
    font-size: 0.78rem;
    line-height: 1;
    pointer-events: none;
    opacity: 0;
    transform: scale(0.6);
    transition: opacity 0.2s, transform 0.2s var(--ease-out);
}

.auth-status-icon[data-state='ok'] { color: var(--moss); opacity: 1; transform: none; }
.auth-status-icon[data-state='no'] { color: var(--ember); opacity: 1; transform: none; }

.auth-hint {
    display: block;
    min-height: 16px;
    margin-top: 4px;
    font-size: 0.77rem;
    font-style: italic;
    color: var(--ink-text);
}

.auth-hint[data-state='ok'] { color: var(--moss); }
.auth-hint[data-state='no'] { color: var(--ember); }
/* Two short fields share a line. This is most of the vertical budget back:
   register drops two full field blocks. */
.auth-pair {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    align-items: start;
}

.auth-pair .auth-field { margin-bottom: 13px; }

/* Reveal button, inside the control so it never shifts the layout. */
.auth-reveal {
    position: absolute;
    right: 5px;
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: var(--ink-500);
    cursor: pointer;
    transition: color 0.18s, background 0.18s;
}

.auth-reveal svg { width: 18px; height: 18px; }
.auth-reveal:hover { color: var(--ink-900); background: rgba(212, 175, 55, 0.16); }
.auth-reveal:focus-visible { outline: 2px solid var(--gold-deep); outline-offset: 1px; }
.auth-reveal[aria-pressed='true'] { color: var(--gold-deep); }

/* Password field with a reveal button needs the padding. */
.auth-control--reveal .auth-input { padding-right: 42px; }

/* ------------------------------------------------------- password rules --- */

.auth-rules {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 6px;
}

/* One chip per rule, mirroring isStrongPassword(). auth.js drives these via
   the data-met attribute, not a class. */
.auth-rule-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px 2px 6px;
    border-radius: 999px;
    border: 1px solid var(--parchment-3);
    background: rgba(255, 255, 255, 0.5);
    font-family: 'Lora', Georgia, serif;
    font-size: 0.7rem;
    line-height: 1.6;
    color: var(--ink-text);
    transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.auth-rule-item::before {
    content: "\25CB";           /* open circle */
    font-size: 0.62rem;
    color: var(--ink-400);
    transition: color 0.2s;
}

.auth-rule-item[data-met='true'] {
    color: var(--moss);
    border-color: rgba(79, 138, 91, 0.45);
    background: rgba(79, 138, 91, 0.1);
}

.auth-rule-item[data-met='true']::before {
    content: "\2713";           /* check */
    color: var(--moss);
}
/* ----------------------------------------------- checkbox, links, CTA --- */

.auth-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 4px 0 16px;
    flex-wrap: wrap;
}

.auth-check {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 0.83rem;
    color: var(--ink-700);
    cursor: pointer;
}

.auth-check input {
    width: 15px;
    height: 15px;
    margin: 0;
    accent-color: var(--gold-deep);
    cursor: pointer;
}

.auth-check input:focus-visible { outline: 2px solid var(--gold-deep); outline-offset: 2px; }

.auth-alt { font-size: 0.83rem; color: var(--ink-700); }

.auth-alt a,
.auth-closer a,
.auth-foot a {
    color: var(--gold-text);
    text-decoration: none;
    border-bottom: 1px solid rgba(124, 99, 24, 0.35);
    transition: color 0.18s, border-color 0.18s;
}

.auth-alt a:hover,
.auth-closer a:hover,
.auth-foot a:hover {
    color: var(--ink-900);
    border-bottom-color: var(--ink-900);
}

.auth-alt a:focus-visible,
.auth-foot a:focus-visible { outline: 2px solid var(--gold-deep); outline-offset: 3px; }

/* -------------------------------------------------------------- submit --- */

.auth-submit {
    position: relative;
    display: block;
    width: 100%;
    padding: 12px 22px;
    font-family: 'Cinzel', Georgia, serif;
    font-size: 0.88rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--cover-2);
    background: linear-gradient(180deg, var(--gold-bright) 0%, var(--gold) 52%, var(--gold-deep) 100%);
    border: 0;
    border-radius: 4px;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.45) inset, 0 4px 14px rgba(154, 123, 30, 0.34);
    cursor: pointer;
    overflow: hidden;
    transition: transform 0.16s var(--ease-out), box-shadow 0.16s, filter 0.16s;
}

.auth-submit:hover { transform: translateY(-1px); box-shadow: 0 1px 0 rgba(255, 255, 255, 0.5) inset, 0 8px 20px rgba(154, 123, 30, 0.42); }
.auth-submit:active { transform: translateY(0); }
.auth-submit:focus-visible { outline: 2px solid var(--ink-900); outline-offset: 2px; }
.auth-submit[disabled] { cursor: wait; filter: saturate(0.55) brightness(0.92); transform: none; }

/* Wipe of light across the gilt on hover. */
.auth-submit::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(105deg, transparent 38%, rgba(255, 255, 255, 0.5) 50%, transparent 62%);
    transform: translateX(-120%);
    transition: transform 0.65s var(--ease-out);
}

.auth-submit:hover::after { transform: translateX(120%); }

.auth-submit.is-done {
    background: linear-gradient(180deg, #63a26f, var(--moss));
    color: #fff;
}

/* -------------------------------------------------------- closing lines --- */

.auth-closer {
    margin: 15px 0 0;
    text-align: center;
    font-size: 0.83rem;
    color: var(--ink-700);
}

.auth-foot {
    margin: 12px 0 0;
    text-align: center;
    font-size: 0.8rem;
}

.auth-foot a { border: 0; opacity: 0.85; }
/* -------------------------------------------------------------- terms --- */

.auth-terms {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 0 0 15px;
    font-size: 0.8rem;
    line-height: 1.45;
    color: var(--ink-700);
    cursor: pointer;
}

.auth-terms input {
    flex: 0 0 auto;
    width: 15px;
    height: 15px;
    margin: 2px 0 0;
    accent-color: var(--gold-deep);
    cursor: pointer;
}

.auth-terms input:focus-visible { outline: 2px solid var(--gold-deep); outline-offset: 2px; }
.auth-terms a { color: var(--gold-text); text-decoration: none; border-bottom: 1px solid rgba(124, 99, 24, 0.35); }
.auth-terms a:hover { color: var(--ink-900); border-bottom-color: var(--ink-900); }

/* -------------------------------------------------------------- motion --- */

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

.auth-book {
    animation: auth-rise 0.6s var(--ease-out) both;
}

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

    .auth-submit:hover { transform: none; }
    .auth-submit:hover::after { transform: none; }
}

/* ---------------------------------------------------------- responsive --- */

/* The cover becomes a slim band above the page. Side-by-side so the seal and
   the lockup stay on one row and the band costs ~78px, not ~180px. */
@media (max-width: 860px) {
    .auth-book {
        grid-template-columns: 1fr;
        max-width: 520px;
    }

    .auth-cover {
        flex-direction: row;
        justify-content: center;
        gap: 14px;
        padding: 14px 18px;
        border-radius: 14px 14px 0 0;
        box-shadow: inset 0 -1px 0 rgba(212, 175, 55, 0.32);
    }

    .auth-cover::before,
    .auth-cover::after { display: none; }

    .auth-seal { height: 46px; flex: 0 0 auto; }

    .auth-cover-kicker {
        margin: 0;
        text-align: left;
        font-size: 0.56rem;
        letter-spacing: 0.14em;
        text-wrap: balance;
    }

    .auth-cover-sub { display: none; }

    .auth-sheet { padding: 22px 20px 20px; }
}

@media (max-width: 560px) {
    .auth-stage { padding: 10px 12px; }

    .auth-book {
        border-radius: 12px;
        box-shadow:
            0 0 0 1px rgba(74, 60, 44, 0.18),
            0 0 0 3px var(--parchment-2),
            0 0 0 4px rgba(154, 123, 30, 0.3),
            0 18px 40px rgba(0, 0, 0, 0.5);
    }

    .auth-sheet { padding: 18px 16px 16px; }
    .auth-seal { height: 40px; }
    .auth-rule { margin-bottom: 11px; }
    .auth-lede { margin-bottom: 13px; font-size: 0.85rem; }

    /* Two-up only earns its keep while there is width for it. */
    .auth-pair { grid-template-columns: 1fr; gap: 0; }

    .auth-input { padding: 9px 12px; font-size: 0.95rem; }
    .auth-row { gap: 8px; margin-bottom: 14px; }
    .auth-submit { padding: 11px 18px; font-size: 0.8rem; }
}

/* Short and wide: claw back vertical rhythm so the page still fits. */
@media (min-width: 861px) and (max-height: 780px) {
    .auth-sheet { padding: 22px 34px; }
    .auth-seal { height: 92px; }
    .auth-field { margin-bottom: 10px; }
    .auth-lede { margin-bottom: 12px; }
    .auth-rule { margin-bottom: 11px; }
    .auth-input { padding: 9px 12px; }
    .auth-closer { margin-top: 12px; }
    .auth-foot { margin-top: 9px; }
    .auth-row { margin-bottom: 13px; }
}