/* ============================================================
   Helix — Base Styles
   
   System font stack, CSS custom properties, shared layout.
   No external dependencies.
   ============================================================ */

/* --- Custom Properties --- */
:root {
    --color-bg:         #0a0a0f;
    --color-surface:    #12121a;
    --color-surface-2:  #1a1a26;
    --color-border:     #2a2a3a;
    --color-border-hover: #3a3a50;

    --color-text:       #e4e4ed;
    --color-text-muted: #8888a0;
    --color-text-dim:   #55556a;

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

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

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

    --radius-sm:  6px;
    --radius-md:  10px;
    --radius-lg:  16px;
    --radius-xl:  24px;

    --shadow-sm:  0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md:  0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg:  0 8px 30px rgba(0, 0, 0, 0.5);

    --transition: 200ms ease;
    --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;
}

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;
}

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;
}

/* --- Navigation --- */
.nav {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(10, 10, 15, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--color-border);
}

.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;
}

.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);
}

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

.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.1);
    border: 1px solid rgba(52, 211, 153, 0.2);
    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 var(--color-border);
    border-radius: var(--radius-lg);
    transition: all var(--transition);
    overflow: hidden;
}

.card:hover {
    border-color: var(--color-border-hover);
    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;
}

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

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

.btn-ghost:hover {
    color: var(--color-text);
    border-color: var(--color-border-hover);
    background: var(--color-surface);
}

.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 var(--color-border);
    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: var(--color-surface);
        border-bottom: 1px solid var(--color-border);
        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: contain; }

/* 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;
    }
}
