/* Red Auth — shared styles for the login and app launcher pages. */

:root {
    --ink: #191410;
    --ink-soft: #453c33;
    --muted: #7b7167;
    --line: #e8e2d8;
    --line-strong: #d8d0c3;
    --paper: #f4f1ea;
    --surface: #fffdf9;
    --brand: #c22a1d;
    --brand-strong: #9d1e13;
    --brand-soft: #fbecea;
    --ok: #1f7a4d;
    --attention: #a15c07;
    --focus: rgba(194, 42, 29, 0.16);
    --shadow-card: 0 30px 70px -34px rgba(25, 20, 16, 0.45),
        0 2px 6px rgba(25, 20, 16, 0.04);
    --shadow-tile: 0 18px 36px -26px rgba(25, 20, 16, 0.4);
    --radius-xl: 24px;
    --radius-lg: 16px;
    --radius-md: 12px;
    --font: "Inter", "Segoe UI", ui-sans-serif, system-ui, -apple-system,
        "Helvetica Neue", Arial, sans-serif;
    --mono: "SFMono-Regular", ui-monospace, "Cascadia Mono", Consolas, monospace;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100dvh;
    font-family: var(--font);
    color: var(--ink);
    background-color: var(--paper);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

button,
input {
    font: inherit;
    color: inherit;
}

a {
    color: var(--brand);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

[hidden] {
    display: none !important;
}

:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}

/* ---------------------------------------------------------------- */
/* Login layout                                                      */
/* ---------------------------------------------------------------- */

.auth-shell {
    display: grid;
    grid-template-columns: minmax(0, 1.02fr) minmax(0, 0.98fr);
    min-height: 100dvh;
}

.brand-panel {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 48px;
    padding: clamp(32px, 5vw, 64px);
    overflow: hidden;
    color: #f6efe7;
    background-color: #171210;
    background-image: radial-gradient(
            120% 90% at 0% 0%,
            rgba(194, 42, 29, 0.42) 0%,
            rgba(194, 42, 29, 0) 55%
        ),
        radial-gradient(
            90% 70% at 100% 100%,
            rgba(209, 144, 74, 0.22) 0%,
            rgba(209, 144, 74, 0) 60%
        );
}

.brand-panel::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0.5;
    background-image: linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px);
    background-size: 72px 72px;
    mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.9), transparent 92%);
}

.brand-panel > * {
    position: relative;
    z-index: 1;
}

.brand-lockup {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-lockup-copy {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.brand-lockup-name {
    font-size: 15px;
    font-weight: 650;
    letter-spacing: 0.01em;
}

.brand-lockup-sub {
    font-size: 12px;
    color: rgba(246, 239, 231, 0.58);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.brand-body {
    max-width: 460px;
    display: flex;
    flex-direction: column;
    gap: 26px;
}

.brand-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    width: fit-content;
    padding: 6px 12px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 999px;
    font-size: 12px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: rgba(246, 239, 231, 0.78);
}

.brand-eyebrow::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #ff7a63;
    box-shadow: 0 0 0 4px rgba(255, 122, 99, 0.16);
}

.brand-title {
    margin: 0;
    font-size: clamp(32px, 3.6vw, 46px);
    line-height: 1.06;
    letter-spacing: -0.032em;
    font-weight: 640;
}

.brand-title em {
    font-style: normal;
    color: #ff9d8c;
}

.brand-copy {
    margin: 0;
    max-width: 40ch;
    font-size: 15px;
    line-height: 1.65;
    color: rgba(246, 239, 231, 0.68);
}

.brand-apps {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    max-width: 400px;
}

.brand-app {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 14px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.04);
    font-size: 13.5px;
    font-weight: 560;
    letter-spacing: 0.01em;
}

.brand-app span {
    color: rgba(246, 239, 231, 0.45);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin-left: auto;
}

.brand-app::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 3px;
    background: currentColor;
    opacity: 0.7;
}

.brand-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: rgba(246, 239, 231, 0.42);
    letter-spacing: 0.02em;
}

.brand-footer strong {
    color: rgba(246, 239, 231, 0.7);
    font-weight: 560;
}

/* ---------------------------------------------------------------- */
/* Form side                                                         */
/* ---------------------------------------------------------------- */

.form-panel {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 18px;
    padding: clamp(24px, 4vw, 56px) clamp(20px, 4vw, 48px);
    background-image: radial-gradient(
        120% 80% at 100% 0%,
        rgba(194, 42, 29, 0.06) 0%,
        rgba(194, 42, 29, 0) 60%
    );
}

.card {
    width: 100%;
    max-width: 424px;
    padding: clamp(24px, 3.4vw, 38px);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-card);
    animation: card-in 420ms cubic-bezier(0.22, 0.68, 0.34, 1) both;
}

@keyframes card-in {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.995);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

.mobile-brand {
    display: none;
    align-items: center;
    gap: 12px;
    margin-bottom: 26px;
}

.card-header {
    margin-bottom: 24px;
}

.card-title {
    margin: 0 0 8px;
    font-size: 26px;
    line-height: 1.15;
    letter-spacing: -0.025em;
    font-weight: 650;
}

.card-subtitle {
    margin: 0;
    font-size: 14px;
    line-height: 1.55;
    color: var(--muted);
}

/* Alerts */

.alert {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    margin-bottom: 16px;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    font-size: 13.5px;
    line-height: 1.5;
    border: 1px solid transparent;
    animation: alert-in 200ms ease both;
}

@keyframes alert-in {
    from {
        opacity: 0;
        transform: translateY(-3px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

.alert svg {
    flex: none;
    width: 17px;
    height: 17px;
    margin-top: 1px;
}

.alert-error {
    background: #fdf0ee;
    border-color: #f4d2cc;
    color: #8e1c12;
}

.alert-info {
    background: #eef6f1;
    border-color: #cfe6d9;
    color: #1c6a45;
}

/* Buttons */

.btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    min-height: 48px;
    padding: 0 18px;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    font-size: 14.5px;
    font-weight: 600;
    letter-spacing: 0.005em;
    cursor: pointer;
    transition: background-color 160ms ease, border-color 160ms ease,
        transform 120ms ease, box-shadow 160ms ease;
    user-select: none;
}

.btn:active:not(:disabled) {
    transform: translateY(1px);
}

.btn:disabled {
    cursor: not-allowed;
    opacity: 0.62;
}

.btn-google {
    background: #fff;
    border-color: var(--line-strong);
    color: var(--ink);
    box-shadow: 0 1px 2px rgba(25, 20, 16, 0.05);
}

.btn-google:hover:not(:disabled) {
    background: #fbf8f3;
    border-color: #c9c0b2;
}

.btn-primary {
    background: var(--brand);
    color: #fff;
    box-shadow: 0 10px 20px -14px rgba(194, 42, 29, 0.9);
}

.btn-primary:hover:not(:disabled) {
    background: var(--brand-strong);
}

.btn.is-loading {
    color: transparent !important;
    pointer-events: none;
}

.btn.is-loading svg {
    opacity: 0;
}

.btn.is-loading::after {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid rgba(25, 20, 16, 0.22);
    border-top-color: rgba(25, 20, 16, 0.75);
    animation: spin 700ms linear infinite;
}

.btn-primary.is-loading::after {
    border-color: rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.google-note {
    margin: 10px 0 0;
    font-size: 12px;
    line-height: 1.5;
    color: var(--muted);
    text-align: center;
}

.divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 22px 0;
    color: var(--muted);
    font-size: 12px;
    letter-spacing: 0.02em;
}

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

/* Form fields */

.field {
    display: flex;
    flex-direction: column;
    gap: 7px;
    margin-bottom: 16px;
}

.field-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}

.field label {
    font-size: 12.5px;
    font-weight: 600;
    letter-spacing: 0.005em;
    color: var(--ink-soft);
}

.field input {
    width: 100%;
    height: 48px;
    padding: 0 14px;
    background: #fff;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-md);
    font-size: 15px;
    color: var(--ink);
    transition: border-color 160ms ease, box-shadow 160ms ease,
        background-color 160ms ease;
}

.field input::placeholder {
    color: #a89e92;
}

.field input:hover:not(:disabled) {
    border-color: #c4bbad;
}

.field input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 4px var(--focus);
}

.field input:disabled {
    background: #f7f4ee;
    color: var(--muted);
    cursor: not-allowed;
}

.field-hint {
    margin: 0;
    font-size: 12.5px;
    line-height: 1.5;
    color: var(--muted);
}

.field-hint strong {
    color: var(--ink-soft);
    font-weight: 600;
    overflow-wrap: anywhere;
}

input#code {
    font-family: var(--mono);
    font-size: 20px;
    letter-spacing: 0.42em;
    text-indent: 0.21em;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.link {
    padding: 0;
    border: 0;
    background: none;
    color: var(--brand);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
}

.link:hover {
    text-decoration: underline;
}

.link[disabled] {
    color: var(--muted);
    cursor: not-allowed;
    text-decoration: none;
}

.link.is-busy {
    color: var(--muted);
    pointer-events: none;
}

.mode-row {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
    margin: 18px 0 0;
    font-size: 12.5px;
    color: var(--muted);
}

.otp-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 4px;
}

.card-footer {
    margin: 22px 0 0;
    padding-top: 18px;
    border-top: 1px solid var(--line);
    font-size: 12.5px;
    line-height: 1.6;
    color: var(--muted);
    text-align: center;
}

.form-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    font-size: 12px;
    color: var(--muted);
}

.form-footer a {
    color: var(--ink-soft);
    text-decoration: underline;
    text-decoration-color: var(--line-strong);
    text-underline-offset: 3px;
}

.noscript {
    max-width: 424px;
    padding: 14px 16px;
    border: 1px solid #f4d2cc;
    border-radius: var(--radius-md);
    background: #fdf0ee;
    color: #8e1c12;
    font-size: 13px;
}

/* ---------------------------------------------------------------- */
/* App launcher                                                      */
/* ---------------------------------------------------------------- */

.portal-shell {
    width: 100%;
    max-width: 1060px;
    margin: 0 auto;
    padding: clamp(24px, 4vw, 56px) clamp(20px, 4vw, 40px) 40px;
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
}

.portal-top .brand-lockup-name {
    color: var(--ink);
}

.portal-top .brand-lockup-sub {
    color: var(--muted);
}

.portal-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding-bottom: 28px;
    border-bottom: 1px solid var(--line);
}

.portal-account {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 44px;
}

.account-pill {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 5px 6px 5px 5px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
}

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--brand-soft);
    color: var(--brand-strong);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.01em;
    flex: none;
}

.account-copy {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
    padding-right: 6px;
}

.account-name {
    font-size: 12.5px;
    font-weight: 620;
}

.account-email {
    font-size: 11.5px;
    color: var(--muted);
    max-width: 190px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink-soft);
    cursor: pointer;
    transition: background-color 150ms ease, border-color 150ms ease;
}

.icon-button:hover {
    background: #faf7f1;
    border-color: var(--line-strong);
}

.portal-hero {
    padding: clamp(30px, 5vw, 52px) 0 30px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.portal-kicker {
    margin: 0;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--brand);
}

.portal-title {
    margin: 0;
    font-size: clamp(28px, 4vw, 40px);
    line-height: 1.08;
    letter-spacing: -0.03em;
    font-weight: 650;
}

.portal-subtitle {
    margin: 0;
    max-width: 52ch;
    font-size: 14.5px;
    line-height: 1.6;
    color: var(--muted);
}

.app-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(238px, 1fr));
    gap: 14px;
}

.app-tile {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 20px;
    min-height: 158px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
    color: inherit;
    text-decoration: none;
    box-shadow: var(--shadow-tile);
    transition: transform 180ms ease, border-color 180ms ease,
        box-shadow 180ms ease;
    animation: tile-in 380ms cubic-bezier(0.22, 0.68, 0.34, 1) both;
}

.app-tile:nth-child(2) {
    animation-delay: 50ms;
}

.app-tile:nth-child(3) {
    animation-delay: 100ms;
}

.app-tile:nth-child(4) {
    animation-delay: 150ms;
}

@keyframes tile-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

.app-tile:hover {
    transform: translateY(-2px);
    border-color: var(--line-strong);
    box-shadow: 0 26px 46px -30px rgba(25, 20, 16, 0.5);
    text-decoration: none;
}

.app-tile:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 3px;
}

.app-tile-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.app-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: #efece5;
    color: var(--ink-soft);
}

/* Colour cycle for any number of apps; the metadata lives in the apps
   collection, so tiles cannot rely on fixed app IDs. */
.app-tile:nth-child(4n + 1) .app-icon {
    background: #e8efff;
    color: #1d4ed8;
}

.app-tile:nth-child(4n + 2) .app-icon {
    background: #fdf0da;
    color: #9a5a06;
}

.app-tile:nth-child(4n + 3) .app-icon {
    background: #fde9e6;
    color: #b42318;
}

.app-tile:nth-child(4n + 4) .app-icon {
    background: #e4f4ec;
    color: #1c6a45;
}

.app-arrow {
    color: var(--muted);
    transition: transform 180ms ease, color 180ms ease;
}

.app-tile:hover .app-arrow {
    transform: translate(2px, -2px);
    color: var(--brand);
}

.app-name {
    margin: 0;
    font-size: 15.5px;
    font-weight: 620;
    letter-spacing: -0.01em;
}

.app-desc {
    margin: 4px 0 0;
    font-size: 12.5px;
    line-height: 1.5;
    color: var(--muted);
}

.portal-empty {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 26px;
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius-lg);
    background: rgba(255, 253, 249, 0.6);
}

.portal-empty h2 {
    margin: 0;
    font-size: 16px;
}

.portal-empty p {
    margin: 0;
    font-size: 13.5px;
    color: var(--muted);
    line-height: 1.55;
}

.portal-footer {
    margin-top: auto;
    padding-top: 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 12px;
    color: var(--muted);
}

.portal-footer .dot {
    margin: 0 7px;
    color: var(--line-strong);
}

/* Skeleton loading */

.skeleton {
    position: relative;
    overflow: hidden;
    background: #ece6db;
    border-radius: 8px;
    color: transparent !important;
}

.skeleton::after {
    content: "";
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.7),
        transparent
    );
    animation: shimmer 1.4s infinite;
}

@keyframes shimmer {
    to {
        transform: translateX(100%);
    }
}

.skeleton-tile {
    min-height: 158px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: linear-gradient(180deg, #f9f6f0, #f2eee6);
}

/* ---------------------------------------------------------------- */
/* Responsive                                                        */
/* ---------------------------------------------------------------- */

@media (max-width: 980px) {
    .auth-shell {
        grid-template-columns: minmax(0, 1fr);
    }

    .brand-panel {
        display: none;
    }

    .mobile-brand {
        display: flex;
    }

    .form-panel {
        min-height: 100dvh;
    }
}

@media (max-width: 560px) {
    .card {
        padding: 24px 20px;
        border-radius: 20px;
    }

    .portal-top {
        padding-bottom: 20px;
    }

    .account-email {
        display: none;
    }

    .portal-footer {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .app-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

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