/*
   OLEVSKIY Private Portal CSS
   Design: Swiss Banker / Minimalist Private Fund Style
   Themes: Warm Porcelain Light / Vaulted Night Dark, both on Bronze-Gold Accents

   Theming model: [data-theme] is written to <html> by app.js (resolved value,
   never "system"). The prefers-color-scheme block below is the no-JS fallback.
*/

/* Inter (variable, 200-700), self-hosted: no third-party font request leaves
   the visitor's browser. Font is SIL Open Font License 1.1. Latin subsets only
   — the page has no Cyrillic or Greek copy. build.sh fingerprints these files
   and rewrites the url() below. */
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 200 700;
    font-display: swap;
    src: url('/assets/inter-latin-ext.a28eb6d3.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304,
        U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0,
        U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 200 700;
    font-display: swap;
    src: url('/assets/inter-latin.c9407645.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
        U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215,
        U+FEFF, U+FFFD;
}

:root {
    color-scheme: light;

    --bg-color: #f7f5f1;
    --card-bg: rgba(255, 255, 255, 0.65);
    --border-color: #e5e0d6;
    --border-focus: #c9c2b4;
    --text-primary: #1d1c1a;
    --text-secondary: #75716a;
    --text-muted: #b0aba1;

    /* Accents */
    --accent-gold: #9c7c45;
    --accent-gold-rgb: 156, 124, 69;
    --accent-green: #2f9e5b;
    --accent-green-rgb: 47, 158, 91;
    --accent-red: #b04a3e;

    /* Atmosphere: grid, orbs, sheen, shadows */
    --grid-line: rgba(29, 28, 26, 0.025);
    --orb-opacity: 0.55;
    --orb-ivory-rgb: 214, 196, 162;
    --orb-pearl-rgb: 255, 255, 255;
    --orb-pearl-strength: 0.85;
    --sheen-color: rgba(255, 255, 255, 0.5);
    --sheen-opacity: 0.35;
    --card-shadow:
        0 1px 2px rgba(29, 28, 26, 0.04),
        0 12px 32px rgba(29, 28, 26, 0.08);
    --control-bg: rgba(255, 255, 255, 0.5);
    --control-thumb: rgba(255, 255, 255, 0.95);

    /* Fonts & Spacing */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --letter-spacing-wide: 0.35em;
    --letter-spacing-mid: 0.15em;
    --letter-spacing-small: 0.08em;
}

/* DARK THEME PALETTE */
:root[data-theme="dark"] {
    color-scheme: dark;

    --bg-color: #100f0d;
    --card-bg: rgba(30, 28, 25, 0.55);
    --border-color: #2c2823;
    --border-focus: #443e35;
    --text-primary: #ece8e0;
    --text-secondary: #97907f;
    --text-muted: #5f594e;

    --accent-gold: #c9a86a;
    --accent-gold-rgb: 201, 168, 106;
    --accent-green: #4fb87a;
    --accent-green-rgb: 79, 184, 122;
    --accent-red: #dd7666;

    --grid-line: rgba(236, 232, 224, 0.03);
    --orb-opacity: 0.4;
    --orb-ivory-rgb: 122, 96, 48;
    --orb-pearl-rgb: 90, 80, 66;
    --orb-pearl-strength: 0.5;
    --sheen-color: rgba(255, 255, 255, 0.045);
    --sheen-opacity: 0.5;
    --card-shadow:
        0 1px 2px rgba(0, 0, 0, 0.3),
        0 12px 32px rgba(0, 0, 0, 0.45);
    --control-bg: rgba(255, 255, 255, 0.04);
    --control-thumb: rgba(255, 255, 255, 0.1);
}

/* No-JS fallback: follow the OS when no explicit choice is on <html> */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        color-scheme: dark;

        --bg-color: #100f0d;
        --card-bg: rgba(30, 28, 25, 0.55);
        --border-color: #2c2823;
        --border-focus: #443e35;
        --text-primary: #ece8e0;
        --text-secondary: #97907f;
        --text-muted: #5f594e;

        --accent-gold: #c9a86a;
        --accent-gold-rgb: 201, 168, 106;
        --accent-green: #4fb87a;
        --accent-green-rgb: 79, 184, 122;
        --accent-red: #dd7666;

        --grid-line: rgba(236, 232, 224, 0.03);
        --orb-opacity: 0.4;
        --orb-ivory-rgb: 122, 96, 48;
        --orb-pearl-rgb: 90, 80, 66;
        --orb-pearl-strength: 0.5;
        --sheen-color: rgba(255, 255, 255, 0.045);
        --sheen-opacity: 0.5;
        --card-shadow:
            0 1px 2px rgba(0, 0, 0, 0.3),
            0 12px 32px rgba(0, 0, 0, 0.45);
        --control-bg: rgba(255, 255, 255, 0.04);
        --control-thumb: rgba(255, 255, 255, 0.1);
    }
}

/* Base resets & layout */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-weight: 300;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color 0.4s ease, color 0.4s ease;
}

/* Theme crossfade for the surfaces that carry palette colors */
.auth-card,
.status-header,
.status-footer,
.security-badge,
.theme-toggle {
    transition: background-color 0.4s ease, border-color 0.4s ease,
                color 0.4s ease, box-shadow 0.4s ease;
}

/* Premium Top Security Line */
.security-line {
    height: 1px;
    width: 100%;
    background: linear-gradient(90deg,
        rgba(var(--accent-gold-rgb), 0) 0%,
        rgba(var(--accent-gold-rgb), 0.7) 50%,
        rgba(var(--accent-gold-rgb), 0) 100%
    );
    background-size: 200% 100%;
    animation: flowLine 8s infinite linear;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 100;
}

/* App structure */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding: 24px;
    justify-content: space-between;
    z-index: 10;
    position: relative;
}

/* ANIMATED BACKGROUND: soft drifting champagne/ivory light fields */
.bg-animation {
    position: fixed;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 0;
}

.bg-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(90px);
    opacity: var(--orb-opacity);
    will-change: transform;
    transition: opacity 0.4s ease;
}

.bg-orb--gold {
    width: 55vmax;
    height: 55vmax;
    top: -20vmax;
    left: -12vmax;
    background: radial-gradient(circle at center,
        rgba(var(--accent-gold-rgb), 0.20) 0%,
        rgba(var(--accent-gold-rgb), 0.06) 45%,
        transparent 70%);
    animation: driftA 38s ease-in-out infinite alternate;
}

.bg-orb--ivory {
    width: 60vmax;
    height: 60vmax;
    bottom: -25vmax;
    right: -15vmax;
    background: radial-gradient(circle at center,
        rgba(var(--orb-ivory-rgb), 0.28) 0%,
        rgba(var(--orb-ivory-rgb), 0.08) 45%,
        transparent 70%);
    animation: driftB 46s ease-in-out infinite alternate;
}

.bg-orb--pearl {
    width: 45vmax;
    height: 45vmax;
    top: 30%;
    left: 35%;
    background: radial-gradient(circle at center,
        rgba(var(--orb-pearl-rgb), var(--orb-pearl-strength)) 0%,
        rgba(var(--orb-pearl-rgb), calc(var(--orb-pearl-strength) * 0.3)) 50%,
        transparent 70%);
    animation: driftC 52s ease-in-out infinite alternate;
}

/* Slow diagonal sheen sweeping across the page */
.bg-animation::after {
    content: "";
    position: absolute;
    inset: -50%;
    background: linear-gradient(115deg,
        transparent 42%,
        var(--sheen-color) 50%,
        transparent 58%);
    animation: sheenSweep 18s ease-in-out infinite;
}

/* Grid overlay background effect for institutional tech feel */
body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-image:
        linear-gradient(var(--grid-line) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
    background-size: 80px 80px;
    background-position: center center;
    pointer-events: none;
    z-index: 1;
}

/* Monospace font utility */
.text-mono {
    font-family: "SF Mono", SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
}

/* HEADER: System Status Bar */
.status-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 16px;
    z-index: 5;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.status-label {
    text-transform: uppercase;
    letter-spacing: var(--letter-spacing-small);
}

.status-val {
    color: var(--text-primary);
}

.status-indicator {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--text-muted);
    display: inline-block;
}

.status-indicator.active {
    background-color: var(--accent-green);
    box-shadow: 0 0 8px rgba(var(--accent-green-rgb), 0.5);
    animation: statusPulse 2s infinite ease-in-out;
}

/* THEME TOGGLE: three-position segmented control (system / light / dark) */
.theme-toggle {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0;
    padding: 2px;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    background-color: var(--control-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* Sliding thumb sits behind the buttons and tracks the active segment */
.theme-toggle__thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 26px;
    height: calc(100% - 4px);
    border-radius: 2px;
    background-color: var(--control-thumb);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
    transform: translateX(calc(var(--thumb-pos, 0) * 26px));
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1),
                background-color 0.4s ease;
    pointer-events: none;
}

.theme-toggle[data-active="light"] { --thumb-pos: 1; }
.theme-toggle[data-active="dark"]  { --thumb-pos: 2; }

.theme-btn {
    position: relative;
    z-index: 1;
    width: 26px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    border-radius: 2px;
    transition: color 0.25s ease;
}

.theme-btn:hover {
    color: var(--text-secondary);
}

.theme-btn[aria-checked="true"] {
    color: var(--accent-gold);
}

.theme-btn:focus-visible {
    outline: 1px solid var(--accent-gold);
    outline-offset: 1px;
}

.theme-btn svg {
    width: 13px;
    height: 13px;
    display: block;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* MAIN PORTAL AREA */
.portal-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 40px;
    padding: 40px 0;
    z-index: 5;
}

/* BRANDING: Swiss Bank Style Minimal Typography */
.branding-section {
    text-align: center;
}

.brand-title {
    font-size: 3.5rem;
    font-weight: 200;
    letter-spacing: var(--letter-spacing-wide);
    color: var(--text-primary);
    line-height: 1.1;
    margin-bottom: 12px;
    text-indent: var(--letter-spacing-wide); /* offset tracking for perfect centering */
    animation: fadeInTitle 1.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.brand-subtitle {
    font-size: 0.85rem;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: var(--letter-spacing-mid);
    color: var(--accent-gold);
    text-indent: var(--letter-spacing-mid);
    animation: fadeInSubtitle 2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.brand-subtitle .divider {
    color: var(--text-muted);
    margin: 0 4px;
}

/* MESSAGE COMPONENT */
.auth-section {
    width: 100%;
    max-width: 440px;
    animation: fadeInCard 1.2s cubic-bezier(0.16, 1, 0.3, 1) 0.3s both;
}

.auth-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 40px 36px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: var(--card-shadow);
    text-align: center;
}

.auth-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 24px;
}

.auth-lock-icon {
    color: var(--accent-gold);
    width: 20px;
    height: 20px;
}

.auth-notice {
    text-align: center;
}

.restricted-notice {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--accent-red);
    letter-spacing: var(--letter-spacing-mid);
    margin-bottom: 16px;
    text-transform: uppercase;
}

.notice-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.6;
    font-weight: 300;
}

.notice-link {
    color: var(--accent-gold);
    text-decoration: none;
    border-bottom: 1px solid rgba(var(--accent-gold-rgb), 0.35);
    transition: border-color 0.25s ease;
}

.notice-link:hover {
    border-bottom-color: var(--accent-gold);
}

/* FOOTER Status Bar */
.status-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border-color);
    padding-top: 16px;
    font-size: 0.7rem;
    color: var(--text-secondary);
    z-index: 5;
}

.footer-segment {
    display: flex;
    align-items: center;
    gap: 8px;
}

.footer-segment.text-right {
    justify-content: flex-end;
}

.footer-segment .label {
    text-transform: uppercase;
    letter-spacing: var(--letter-spacing-small);
}

.security-badge {
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 4px;
    background-color: rgba(var(--accent-green-rgb), 0.08);
    border: 1px solid rgba(var(--accent-green-rgb), 0.25);
    border-radius: 3px;
    padding: 2px 6px;
    font-weight: 500;
}

.shield-icon {
    width: 10px;
    height: 10px;
    color: var(--accent-green);
}

.ip-label {
    letter-spacing: var(--letter-spacing-small);
}

.ip-val {
    color: var(--text-primary);
}

/* MOBILE RESPONSIVENESS */
@media (max-width: 768px) {
    .status-header {
        padding-bottom: 12px;
    }
    .hide-mobile {
        display: none;
    }
    .brand-title {
        font-size: 2.5rem;
    }
    .portal-main {
        gap: 30px;
    }
    .status-footer {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }
    .footer-segment,
    .footer-segment.text-right {
        justify-content: center;
        width: 100%;
    }
}

/* ACCESSIBILITY: respect reduced-motion preference */
@media (prefers-reduced-motion: reduce) {
    .bg-orb,
    .bg-animation::after,
    .security-line {
        animation: none;
    }
    .theme-toggle__thumb {
        transition: none;
    }
}

/* ANIMATIONS */
@keyframes flowLine {
    0% { background-position: 0% 50%; }
    100% { background-position: 200% 50%; }
}

@keyframes statusPulse {
    0%, 100% { opacity: 0.6; box-shadow: 0 0 4px rgba(var(--accent-green-rgb), 0.4); }
    50% { opacity: 1; box-shadow: 0 0 10px rgba(var(--accent-green-rgb), 0.6); }
}

@keyframes driftA {
    0%   { transform: translate(0, 0) scale(1); }
    50%  { transform: translate(8vmax, 6vmax) scale(1.08); }
    100% { transform: translate(14vmax, 2vmax) scale(0.96); }
}

@keyframes driftB {
    0%   { transform: translate(0, 0) scale(1); }
    50%  { transform: translate(-10vmax, -5vmax) scale(1.06); }
    100% { transform: translate(-4vmax, -10vmax) scale(1.12); }
}

@keyframes driftC {
    0%   { transform: translate(0, 0) scale(1); }
    50%  { transform: translate(-6vmax, 5vmax) scale(1.15); }
    100% { transform: translate(5vmax, -4vmax) scale(0.92); }
}

@keyframes sheenSweep {
    0%, 100% { transform: translateX(-30%); opacity: 0; }
    10%      { opacity: var(--sheen-opacity); }
    50%      { transform: translateX(30%); opacity: var(--sheen-opacity); }
    90%      { opacity: var(--sheen-opacity); }
}

@keyframes fadeInTitle {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInSubtitle {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fadeInCard {
    from {
        opacity: 0;
        transform: translateY(15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
