@layer reset, tokens, base, layout, components, marketing, responsive;

@layer reset {
    *, *::before, *::after { box-sizing: border-box; }
    html { min-height: 100%; }
    body, h1, h2, h3, p, ul, fieldset { margin: 0; }
    input, select, button { font: inherit; }
    img, svg { display: block; max-width: 100%; }
}

@layer tokens {
    :root {
        --brand-navy: #020617;
        --brand-panel: #0f172a;
        --brand-panel-soft: #162033;
        --brand-line: #1e293b;
        --brand-blue: #2563eb;
        --brand-blue-hover: #3b82f6;
        --brand-blue-light: #60a5fa;
        --brand-cyan: #38bdf8;
        --page: #f5f8fc;
        --surface: #fcfdff;
        --surface-muted: #f1f5f9;
        --ink: #0f172a;
        --muted: #64748b;
        --line: #dbe3ee;
        --danger: #be123c;
        --danger-wash: #fff1f2;
        --success: #047857;
        --success-wash: #ecfdf5;
        --font: "Instrument Sans", ui-sans-serif, system-ui, sans-serif;
        --ease-out-quint: cubic-bezier(0.22, 1, 0.36, 1);
    }
}

@layer base {
    body {
        min-height: 100vh;
        color: var(--ink);
        background: var(--brand-navy);
        font-family: var(--font);
        line-height: 1.5;
        -webkit-font-smoothing: antialiased;
    }

    a {
        color: var(--brand-blue);
        font-weight: 600;
        text-decoration-thickness: 1px;
        text-underline-offset: 0.2em;
    }

    a:hover { color: var(--brand-blue-hover); }

    :focus-visible {
        outline: 3px solid color-mix(in srgb, var(--brand-blue-light) 68%, transparent);
        outline-offset: 3px;
    }

    h1, h2, h3 {
        color: var(--ink);
        font-weight: 700;
        letter-spacing: -0.045em;
        line-height: 1.02;
        text-wrap: balance;
    }

    h1 { font-size: clamp(2.25rem, 4vw, 3.15rem); }
    h2 { font-size: clamp(3.2rem, 6vw, 5.9rem); }
}

@layer layout {
    .auth-chart {
        position: fixed;
        z-index: -1;
        inset: 0;
        overflow: hidden;
        background:
            radial-gradient(circle at 5% 100%, rgb(37 99 235 / 0.26), transparent 34rem),
            radial-gradient(circle at 86% 5%, rgb(8 66 152 / 0.2), transparent 28rem),
            var(--brand-navy);
        pointer-events: none;
    }

    .auth-chart::after {
        position: absolute;
        inset: 0;
        background-image:
            linear-gradient(rgb(96 165 250 / 0.035) 1px, transparent 1px),
            linear-gradient(90deg, rgb(96 165 250 / 0.035) 1px, transparent 1px);
        background-size: 4rem 4rem;
        mask-image: linear-gradient(to right, black, transparent 58%);
        content: "";
    }

    .auth-chart span {
        position: absolute;
        width: 52rem;
        height: 52rem;
        border: 1px solid rgb(96 165 250 / 0.08);
        border-radius: 50%;
    }

    .auth-chart span:nth-child(1) { right: 58%; bottom: -37rem; }
    .auth-chart span:nth-child(2) { right: 67%; bottom: -40rem; }
    .auth-chart span:nth-child(3) { display: none; }

    .auth-shell {
        display: grid;
        width: min(100% - 2rem, 34rem);
        min-height: 100vh;
        margin-inline: auto;
        align-items: center;
        padding: 3rem 0;
    }

    .auth-shell--split {
        width: 100%;
        max-width: none;
        grid-template-columns: minmax(31rem, 1fr) minmax(31rem, 1fr);
        padding: 0;
    }

    .auth-side {
        position: relative;
        display: flex;
        min-height: 100vh;
        flex-direction: column;
        justify-content: space-between;
        overflow: hidden;
        padding: clamp(2.5rem, 5vw, 5.75rem);
        color: #f8fafc;
        background:
            radial-gradient(circle at 12% 92%, rgb(37 99 235 / 0.24), transparent 27rem),
            radial-gradient(circle at 92% 8%, rgb(8 66 152 / 0.2), transparent 24rem),
            var(--brand-navy);
    }

    .auth-side::before {
        position: absolute;
        inset: 0;
        background:
            linear-gradient(125deg, transparent 32%, rgb(96 165 250 / 0.045) 32.1%, transparent 32.35%),
            linear-gradient(145deg, transparent 64%, rgb(96 165 250 / 0.055) 64.1%, transparent 64.35%);
        content: "";
        pointer-events: none;
    }

    .auth-logo {
        position: relative;
        z-index: 1;
        display: block;
        width: 10.5rem;
    }

    .auth-logo img { width: 100%; }

    .auth-logo--compact {
        width: 9.5rem;
        margin: 0 auto 2rem;
    }

    .auth-side__content {
        position: relative;
        z-index: 1;
        width: min(100%, 44rem);
        padding-block: 4rem;
        animation: auth-enter 700ms var(--ease-out-quint) both;
    }

    .auth-side__content h2 {
        max-width: 10ch;
        color: #f8fafc;
        font-size: clamp(3.5rem, 5.2vw, 6.25rem);
    }

    .auth-side__content h2 span {
        display: block;
        color: var(--brand-blue-light);
        background: linear-gradient(90deg, var(--brand-blue-light), var(--brand-cyan));
        background-clip: text;
        -webkit-text-fill-color: transparent;
    }

    .side__badge {
        display: inline-flex;
        width: fit-content;
        align-items: center;
        gap: 0.55rem;
        margin-bottom: 2rem;
        border: 1px solid rgb(148 163 184 / 0.22);
        border-radius: 999px;
        padding: 0.55rem 0.85rem;
        color: #cbd5e1;
        background: rgb(15 23 42 / 0.72);
        font-size: 0.82rem;
        font-weight: 600;
    }

    .side__badge svg {
        width: 1rem;
        fill: none;
        stroke: var(--brand-blue-light);
        stroke-linecap: round;
        stroke-linejoin: round;
        stroke-width: 2;
    }

    .side__lede {
        max-width: 35rem;
        margin-top: 1.75rem;
        color: #94a3b8;
        font-size: clamp(1rem, 1.5vw, 1.2rem);
        line-height: 1.7;
    }

    .side__list {
        display: grid;
        max-width: 40rem;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 0.75rem;
        margin-top: 2.5rem;
        padding: 0;
        list-style: none;
    }

    .side__list li {
        min-height: 7.5rem;
        border: 1px solid rgb(148 163 184 / 0.16);
        border-radius: 0.75rem;
        padding: 1rem;
        color: #cbd5e1;
        background: rgb(15 23 42 / 0.7);
        backdrop-filter: blur(0.75rem);
    }

    .side__list strong, .side__list span { display: block; }
    .side__list strong { margin-bottom: 0.45rem; color: #f8fafc; font-size: 0.88rem; }
    .side__list span { color: #94a3b8; font-size: 0.75rem; line-height: 1.5; }
    .side__foot { margin-top: 1.5rem; color: #94a3b8; }
    .side__foot a { color: var(--brand-blue-light); }

    .auth-side__bearing {
        position: relative;
        z-index: 1;
        color: #64748b;
        font-size: 0.7rem;
        font-weight: 700;
        letter-spacing: 0.14em;
        text-transform: uppercase;
    }

    .auth-form-stage {
        position: relative;
        z-index: 1;
        width: min(100% - 2rem, 31rem);
        margin-inline: auto;
        padding: 3rem 0;
        animation: auth-enter 650ms 80ms var(--ease-out-quint) both;
    }

    .auth-shell--split .auth-form-stage {
        display: flex;
        width: 100%;
        max-width: none;
        min-height: 100vh;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 3rem clamp(1.5rem, 5vw, 5rem);
        background:
            radial-gradient(circle at 100% 0%, rgb(37 99 235 / 0.08), transparent 25rem),
            var(--page);
    }

    .auth-card {
        width: 100%;
        border: 1px solid var(--line);
        border-radius: 1rem;
        padding: clamp(1.75rem, 4vw, 2.75rem);
        background: var(--surface);
        box-shadow: 0 1.5rem 4rem rgb(15 23 42 / 0.12);
    }

    .auth-shell--split .auth-card, .auth-shell--split .auth-foot { width: min(100%, 29rem); }

    .auth-card__hero { margin-bottom: 1.5rem; }
    .auth-card__hero h1 { margin-bottom: 0.65rem; }
    .auth-card > h1 { margin-bottom: 0.75rem; }
    .auth-card .muted { color: var(--muted); }

    .auth-eyebrow {
        margin-bottom: 0.75rem;
        color: var(--brand-blue);
        font-size: 0.7rem;
        font-weight: 700;
        letter-spacing: 0.13em;
        text-transform: uppercase;
    }

    .auth-foot {
        padding: 1.25rem 0;
        color: var(--muted);
        text-align: center;
        font-size: 0.86rem;
    }
}

@layer components {
    .auth-card form { margin-top: 1.35rem; }

    .auth-card label, .colour-fieldset legend {
        display: block;
        margin: 1rem 0 0.4rem;
        color: #334155;
        font-size: 0.8rem;
        font-weight: 600;
    }

    .auth-card input, .auth-card select {
        width: 100%;
        min-height: 3.25rem;
        border: 1px solid var(--line);
        border-radius: 0.55rem;
        padding: 0.72rem 0.9rem;
        color: var(--ink);
        background: var(--surface);
        transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
    }

    .auth-card input::placeholder { color: #94a3b8; }

    .auth-card input:focus, .auth-card select:focus {
        border-color: var(--brand-blue);
        outline: 0;
        box-shadow: 0 0 0 3px rgb(37 99 235 / 0.12);
    }

    .auth-input {
        display: flex;
        min-height: 3.35rem;
        align-items: center;
        border: 1px solid var(--line);
        border-radius: 0.6rem;
        background: var(--surface);
        transition: border-color 160ms ease, box-shadow 160ms ease;
    }

    .auth-input:focus-within {
        border-color: var(--brand-blue);
        box-shadow: 0 0 0 3px rgb(37 99 235 / 0.12);
    }

    .auth-input > svg {
        width: 1.1rem;
        margin-left: 0.95rem;
        flex: 0 0 auto;
        fill: none;
        stroke: #64748b;
        stroke-linecap: round;
        stroke-linejoin: round;
        stroke-width: 1.7;
    }

    .auth-card .auth-input input {
        min-height: 3.2rem;
        border: 0;
        background: transparent;
        box-shadow: none;
    }

    .auth-form-options {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 1rem;
        margin-top: 1rem;
        font-size: 0.82rem;
    }

    .remember-choice {
        display: inline-flex !important;
        align-items: center;
        gap: 0.55rem;
        margin: 0 !important;
        color: var(--muted) !important;
        cursor: pointer;
    }

    .auth-card .remember-choice input {
        width: 1rem;
        min-height: 1rem;
        margin: 0;
        accent-color: var(--brand-blue);
    }

    .auth-card button[type="submit"] {
        display: flex;
        width: 100%;
        min-height: 3.25rem;
        align-items: center;
        justify-content: center;
        gap: 0.65rem;
        margin-top: 1.35rem;
        border: 0;
        border-radius: 0.6rem;
        padding: 0.75rem 1rem;
        color: #f8fafc;
        background: var(--brand-blue);
        box-shadow: 0 0.75rem 1.75rem rgb(37 99 235 / 0.2);
        font-weight: 700;
        cursor: pointer;
        transition: transform 180ms var(--ease-out-quint), background 180ms ease, box-shadow 180ms ease;
    }

    .auth-card button[type="submit"] svg {
        width: 1rem;
        fill: none;
        stroke: currentColor;
        stroke-linecap: round;
        stroke-linejoin: round;
        stroke-width: 2;
        transition: transform 180ms var(--ease-out-quint);
    }

    .auth-card button[type="submit"]:hover {
        background: var(--brand-blue-hover);
        box-shadow: 0 1rem 2rem rgb(37 99 235 / 0.28);
        transform: translateY(-1px);
    }

    .auth-card button[type="submit"]:hover svg { transform: translateX(0.2rem); }

    .error {
        margin-top: 0.4rem;
        border-radius: 0.45rem;
        padding: 0.5rem 0.65rem;
        color: var(--danger);
        background: var(--danger-wash);
        font-size: 0.8rem;
        font-weight: 600;
    }

    .field-hint { margin-top: 0.4rem; color: var(--muted); font-size: 0.78rem; }
    .form-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; }

    .terms-choice {
        display: flex !important;
        align-items: flex-start;
        gap: 0.6rem;
        cursor: pointer;
    }

    .auth-card .terms-choice input { width: auto; min-height: 0; margin-top: 0.22rem; }

    .social-auth { margin: 1.4rem 0; }

    .social-btn {
        display: flex;
        min-height: 3.15rem;
        align-items: center;
        justify-content: center;
        gap: 0.65rem;
        border: 1px solid var(--line);
        border-radius: 0.6rem;
        color: var(--ink);
        background: var(--surface);
        font-weight: 700;
        text-decoration: none;
    }

    .social-btn:hover { border-color: #b8c4d4; color: var(--ink); background: var(--surface-muted); }

    .social-auth__divider {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        margin: 1rem 0;
        color: var(--muted);
        font-size: 0.72rem;
    }

    .social-auth__divider::before, .social-auth__divider::after { height: 1px; flex: 1; background: var(--line); content: ""; }

    .club-preview { display: flex; justify-content: flex-start; margin-bottom: 1.25rem; }

    .club-preview__badge {
        display: grid;
        width: 4rem;
        height: 4rem;
        place-items: center;
        border-radius: 0.65rem;
        color: #f8fafc;
        font-size: 0.95rem;
        font-weight: 700;
    }

    .club-preview__badge img { width: 100%; height: 100%; object-fit: contain; }

    .slug-field {
        display: flex;
        align-items: stretch;
        border: 1px solid var(--line);
        border-radius: 0.55rem;
        background: var(--surface);
    }

    .slug-field input { min-width: 0; border: 0; background: transparent; box-shadow: none; }

    .slug-field__suffix {
        display: flex;
        align-items: center;
        padding: 0 0.75rem;
        border-left: 1px solid var(--line);
        color: var(--muted);
        font-size: 0.72rem;
        font-weight: 600;
    }

    .colour-fieldset { margin: 1.1rem 0 0; border: 0; padding: 0; }
    .colour-picker { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0.55rem; }
    .colour-choice { position: relative; margin: 0 !important; text-align: center; cursor: pointer; }
    .auth-card .colour-choice input { position: absolute; width: 1px; height: 1px; min-height: 0; opacity: 0; }
    .colour-choice span { display: block; height: 2.8rem; border: 3px solid var(--surface); border-radius: 0.55rem; background: var(--swatch); outline: 1px solid var(--line); }
    .colour-choice input:checked + span { outline: 3px solid var(--brand-blue); outline-offset: 2px; }
    .colour-choice small { display: block; margin-top: 0.4rem; color: var(--muted); font-size: 0.62rem; }

    @keyframes auth-enter {
        from { opacity: 0; transform: translateY(1.25rem); }
        to { opacity: 1; transform: translateY(0); }
    }
}

@layer marketing {
    .marketing-body { color: #f8fafc; background: var(--brand-navy); }
    .marketing-nav, .marketing-foot__inner, .marketing-shell { width: min(100% - 2rem, 72rem); margin-inline: auto; }
    .marketing-nav { display: flex; align-items: center; justify-content: space-between; padding: 1.25rem 0; }
    .marketing-nav__brand { display: flex; align-items: center; gap: 0.65rem; color: #f8fafc; font-size: 1.15rem; text-decoration: none; }
    .marketing-nav__links, .marketing-foot__links { display: flex; align-items: center; gap: 1rem; }
    .marketing-nav a, .marketing-foot a { color: #cbd5e1; }
    .marketing-nav__cta { border-radius: 0.55rem; padding: 0.65rem 0.9rem; color: #f8fafc !important; background: var(--brand-blue); }
    .marketing-shell { min-height: calc(100vh - 10rem); padding: 4rem 0; }
    .marketing-foot { border-top: 1px solid var(--brand-line); color: #64748b; }
    .marketing-foot__inner { display: flex; justify-content: space-between; gap: 1rem; padding: 1.5rem 0; }
}

@layer responsive {
    @media (max-width: 1080px) {
        .auth-shell--split { grid-template-columns: minmax(26rem, 0.95fr) minmax(28rem, 1.05fr); }
        .side__list { grid-template-columns: 1fr; }
        .side__list li { min-height: 0; }
    }

    @media (max-width: 860px) {
        .auth-shell--split { grid-template-columns: 1fr; }
        .auth-side { min-height: auto; padding: 1.1rem 1.5rem; }
        .auth-logo { width: 8.75rem; }
        .auth-side__content, .auth-side__bearing { display: none; }
        .auth-shell--split .auth-form-stage { min-height: calc(100vh - 5.5rem); justify-content: flex-start; padding: 2.75rem 1rem; }
    }

    @media (max-width: 520px) {
        .auth-shell, .auth-form-stage { width: min(100% - 1rem, 31rem); }
        .auth-card { border-radius: 0.85rem; padding: 1.4rem; }
        .auth-form-options { align-items: flex-start; }
        .form-pair { grid-template-columns: 1fr; gap: 0; }
        .colour-picker { grid-template-columns: repeat(3, minmax(0, 1fr)); }
        .slug-field { display: block; }
        .slug-field__suffix { min-height: 2.5rem; border-top: 1px solid var(--line); border-left: 0; }
        .marketing-nav__links { display: none; }
        .marketing-foot__inner { flex-direction: column; }
    }

    @media (prefers-reduced-motion: reduce) {
        .auth-side__content, .auth-form-stage { animation: none; }
        .auth-card button[type="submit"], .auth-card button[type="submit"] svg { transition: none; }
    }
}
