/* ============================================================
   Helix — Base Styles
   
   Inter font, CSS custom properties, shared layout.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* --- Custom Properties --- */
:root {
    --color-bg:         #09090b;
    --color-surface:    #111113;
    --color-surface-2:  #18181b;
    --color-border:     rgba(255, 255, 255, 0.06);
    --color-border-hover: rgba(255, 255, 255, 0.1);

    --color-text:       #ececf1;
    --color-text-muted: #8e8ea0;
    --color-text-dim:   #52525b;

    --color-accent:     #7c6aef;
    --color-accent-hover: #9584f7;
    --color-accent-glow: rgba(124, 106, 239, 0.12);

    --color-success:    #34d399;
    --color-warning:    #fbbf24;
    --color-error:      #f87171;

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI',
                 Roboto, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;

    --radius-sm:  8px;
    --radius-md:  12px;
    --radius-lg:  16px;
    --radius-xl:  24px;

    --shadow-sm:  0 1px 2px rgba(0, 0, 0, 0.15), 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md:  0 4px 6px rgba(0, 0, 0, 0.1), 0 10px 20px rgba(0, 0, 0, 0.15);
    --shadow-lg:  0 8px 16px rgba(0, 0, 0, 0.1), 0 20px 40px rgba(0, 0, 0, 0.2);
    --shadow-glow: 0 0 0 1px rgba(255, 255, 255, 0.03), 0 4px 16px rgba(0, 0, 0, 0.2);

    --transition: 300ms cubic-bezier(0.16, 1, 0.3, 1);
    --transition-fast: 150ms cubic-bezier(0.16, 1, 0.3, 1);
    --max-width:  1200px;
}

/* --- Reset --- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
    text-rendering: optimizeLegibility;
    font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
    overflow-x: hidden;
    /* Preserve native browser panning on Android/WebView scroll stacks. */
    touch-action: auto;
    -ms-touch-action: auto;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-sans);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
    position: relative;
    animation: pageEnter 0.38s cubic-bezier(0.16, 1, 0.3, 1);
}

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

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

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

a:hover {
    color: var(--color-accent-hover);
}

img {
    display: block;
    max-width: 100%;
    height: auto;
}

/* --- Layout --- */
.container {
    width: 100%;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 24px;
}

main {
    flex: 1;
}

/* --- Global Motion (lightweight) --- */
.reveal-on-scroll {
    opacity: 0;
    transform: translateY(16px) scale(0.99);
    filter: blur(2px);
    transition:
        opacity 520ms cubic-bezier(0.16, 1, 0.3, 1),
        transform 520ms cubic-bezier(0.16, 1, 0.3, 1),
        filter 520ms cubic-bezier(0.16, 1, 0.3, 1);
    transition-delay: var(--reveal-delay, 0ms);
}

.reveal-on-scroll.is-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
}

/* --- Navigation --- */
.nav {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(9, 9, 11, 0.8);
    backdrop-filter: blur(20px) saturate(1.2);
    -webkit-backdrop-filter: blur(20px) saturate(1.2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.nav .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--color-text);
    letter-spacing: -0.5px;
}

.nav-brand:hover {
    color: var(--color-text);
}

.nav-brand svg {
    width: 28px;
    height: 28px;
    stroke: var(--color-accent);
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

@media (hover: hover) and (pointer: fine) {
    .nav-brand svg {
        transition: transform 420ms cubic-bezier(0.16, 1, 0.3, 1);
    }

    .nav-brand:hover svg {
        transform: translateY(-1px) rotate(-7deg) scale(1.04);
    }
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 8px;
    list-style: none;
}

.nav-links a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    color: var(--color-text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition);
    position: relative;
}

.nav-links a::after {
    content: '';
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: 6px;
    height: 2px;
    border-radius: 999px;
    background: linear-gradient(90deg, rgba(124, 106, 239, 0.2) 0%, rgba(124, 106, 239, 0.95) 50%, rgba(124, 106, 239, 0.2) 100%);
    transform: scaleX(0);
    transform-origin: left center;
    transition: transform 320ms cubic-bezier(0.16, 1, 0.3, 1);
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--color-text);
    background: rgba(255, 255, 255, 0.05);
}

.nav-links a:hover::after,
.nav-links a.active::after {
    transform: scaleX(1);
}

.nav-links a svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Mobile nav toggle */
.nav-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--color-text);
    cursor: pointer;
    padding: 8px;
}

.nav-toggle svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

/* --- Status Badge --- */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 500;
    background: rgba(52, 211, 153, 0.08);
    border: 1px solid rgba(52, 211, 153, 0.12);
    color: var(--color-success);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-success);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* --- Cards --- */
.card {
    background: var(--color-surface);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-glow);
    transition: all var(--transition);
    overflow: hidden;
}

.card:hover {
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all var(--transition);
}

.btn-primary {
    background: var(--color-accent);
    color: #fff;
    position: relative;
    overflow: hidden;
}

.btn-primary::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(120deg, transparent 20%, rgba(255, 255, 255, 0.22) 50%, transparent 80%);
    transform: translateX(-140%);
    transition: transform 650ms cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
}

.btn-primary:hover {
    background: var(--color-accent-hover);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 16px var(--color-accent-glow);
}

.btn-primary:hover::after {
    transform: translateX(140%);
}

.btn-ghost {
    background: transparent;
    color: var(--color-text-muted);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.btn-ghost:hover {
    color: var(--color-text);
    border-color: rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.04);
}

.btn svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* --- Footer --- */
.footer {
    border-top: 1px solid rgba(255, 255, 255, 0.04);
    padding: 32px 0;
    margin-top: 80px;
    text-align: center;
    color: var(--color-text-dim);
    font-size: 0.85rem;
}

.footer a {
    color: var(--color-text-muted);
}

.footer a:hover {
    color: var(--color-accent);
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .container {
        padding: 0 16px;
    }

    .nav-links {
        display: none;
        position: absolute;
        top: 64px;
        left: 0;
        right: 0;
        flex-direction: column;
        background: rgba(9, 9, 11, 0.95);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border-bottom: 1px solid rgba(255, 255, 255, 0.04);
        padding: 12px;
        gap: 4px;
    }

    .nav-links.open {
        display: flex;
    }

    .nav-links a {
        width: 100%;
        padding: 12px 16px;
    }

    .nav-toggle {
        display: block;
    }
}

/* --- Utilities --- */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

.text-muted {
    color: var(--color-text-muted);
}

.text-dim {
    color: var(--color-text-dim);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   iOS / Mobile Optimizations
   ═══════════════════════════════════════════════════════════════════════════════ */

/* Safe area insets for notch/home indicator */
@supports (padding: env(safe-area-inset-top)) {
    .nav { padding-top: env(safe-area-inset-top); }
    .footer { padding-bottom: env(safe-area-inset-bottom); }
    body { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
}

/* iOS standalone (Add to Home Screen) */
@media (display-mode: standalone) {
    .nav { padding-top: env(safe-area-inset-top, 20px); }
    body { overscroll-behavior: none; -webkit-overflow-scrolling: touch; }
}

/* Touch-friendly tap targets (44px min per Apple HIG) */
@media (pointer: coarse) {
    .nav-links a { min-height: 44px; display: inline-flex; align-items: center; }
    .nav-toggle { min-width: 44px; min-height: 44px; }
    .btn, a.btn { min-height: 44px; padding: 10px 18px; }
    .nav-links a:hover, .btn:hover { transform: none; }
    .nav-links a:active, .btn:active { transform: scale(0.97); transition-duration: 50ms; }
}

/* Prevent text selection on interactive elements */
.nav, .nav-toggle, .btn { -webkit-user-select: none; user-select: none; }

/* iOS rubber-band overscroll fix */
body { overscroll-behavior-y: auto; }

/* Keep mobile scroll compositor work minimal on touch-only devices. */
@media (hover: none) and (pointer: coarse) {
    .reveal-on-scroll,
    .reveal-on-scroll.is-visible {
        opacity: 1;
        transform: none;
        filter: none;
        transition: none;
    }

    .nav,
    .nav-links {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
}

/* Fix iOS input zoom — ensure 16px on all inputs */
@media screen and (max-width: 768px) {
    input[type="text"], input[type="password"], input[type="search"],
    input[type="email"], select, textarea {
        font-size: 16px !important;
    }
}
