:root {
    --bg: #ffffff;
    --fg: #111111;
    --muted: #666666;
    --rx: 0deg;
    --ry: 0deg;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0b0d10;
        --fg: #e6e9ef;
        --muted: #a0a6b0;
    }
}

/* Manual overrides via data-theme take precedence over system preference */
[data-theme="light"] {
    --bg: #ffffff;
    --fg: #111111;
    --muted: #666666;
}

[data-theme="dark"] {
    --bg: #0b0d10;
    --fg: #e6e9ef;
    --muted: #a0a6b0;
}

html, body {
    height: 100%;
}

html {
    scroll-behavior: smooth;
}

html.no-smooth {
    scroll-behavior: auto !important;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--fg);
    font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, 'Helvetica Neue', Arial, 'Noto Sans', 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
    min-height: 100vh;
    overflow-anchor: none;
}

/* Top navigation */
.top-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    padding: 8px 0;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-bottom: none;
    text-align: center;
}

.nav-content {
    display: inline-flex;
    gap: 0.75rem;
    align-items: center;
    padding: 10px 14px;
    margin: 10px auto;
    border-radius: 999px;
    background: color-mix(in srgb, var(--bg) 65%, transparent);
    border: 1px solid color-mix(in srgb, var(--fg) 12%, transparent);
    box-shadow: 0 6px 16px color-mix(in srgb, var(--fg) 8%, transparent);
    -webkit-backdrop-filter: blur(10px) saturate(140%);
    backdrop-filter: blur(10px) saturate(140%);
}

.nav-btn {
    color: var(--fg);
    text-decoration: none;
    font-size: 15px;
    padding: 8px 12px;
    border-radius: 999px;
    border: none;
    opacity: 0;
    transform: translateY(6px);
    animation: fadeInUp 520ms ease-out forwards;
}

.nav-btn:hover, .nav-btn:focus-visible {
    background: color-mix(in srgb, var(--fg) 8%, transparent);
}

/* staggered fade-in for nav buttons */
.nav-content .nav-btn:nth-child(1) { animation-delay: 0ms; }
.nav-content .nav-btn:nth-child(2) { animation-delay: 60ms; }
.nav-content .nav-btn:nth-child(3) { animation-delay: 120ms; }
.nav-content .nav-btn:nth-child(4) { animation-delay: 180ms; }

main {
    padding: clamp(2rem, 8vw, 6rem);
    min-height: 100svh;
    min-height: 100vh;
    display: flex;
    align-items: center;
}

h1 {
    font-size: clamp(2.5rem, 8vw, 4.5rem);
    line-height: 1.1;
    margin: 0;
}

.warpable {
    transform: scale(var(--sx, 1), var(--sy, 1));
    transform-style: flat;
    transition: transform 160ms ease-out;
    will-change: transform;
}

/* Sections */
section {
    padding: clamp(2rem, 8vw, 6rem);
    scroll-margin-top: 96px;
    min-height: 100svh;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
}

section h2 {
    font-size: clamp(1.5rem, 4vw, 2rem);
    line-height: 1.2;
    margin: 0 0 0.75rem 0;
    font-size: 48px;
}

section p {
    color: var(--muted);
    max-width: 70ch;
    font-size: 1.05rem;
    line-height: 1.7;
    margin: 0;
    font-size: 24px;
}

.social-links {
    display: flex;
    flex-direction: row;
    gap: 0.75rem;
    margin-left: clamp(1rem, 4vw, 2rem);
    width: 100%;
    max-width: 420px;
}

.social-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--fg);
    text-decoration: none;
    font-size: clamp(14px, 1.6vw, 18px);
    padding: 12px 16px;
    border-radius: 999px;
    border: 1px solid color-mix(in srgb, var(--fg) 12%, transparent);
    background: color-mix(in srgb, var(--bg) 65%, transparent);
    box-shadow: 0 6px 16px color-mix(in srgb, var(--fg) 8%, transparent);
    transition: background 160ms ease-out, transform 160ms ease-out;
    width: 360px;
}

.social-link:hover, .social-link:focus-visible {
    background: color-mix(in srgb, var(--fg) 8%, transparent);
}

.bubble {
    width: 100px;
    height: 100px;
    background: color-mix(in srgb, var(--fg) 8%, transparent);
    border-radius: 20px;
}

/* Projects section layout */
#projects {
    flex-direction: column;
    align-items: flex-start;
}

.section-content {
    width: 100%;
}

/* Projects container and bubbles */
.projects-container {
    display: flex;
    gap: 2rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 2rem;
    width: 100%;
}

.project-bubble {
    width: 350px;
    height: 250px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border: 1px solid color-mix(in srgb, var(--fg) 12%, transparent);
    box-shadow: 0 4px 12px color-mix(in srgb, var(--fg) 8%, transparent);
}

.project-bubble:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px color-mix(in srgb, var(--fg) 15%, transparent);
}

.project-content h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1.2rem;
    color: var(--fg);
}

.project-content p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--muted);
    line-height: 1.4;
}

/* Responsive design for project bubbles */
@media (max-width: 920px) {
    .projects-container {
        gap: 1.5rem;
    }
    
    .project-bubble {
        width: 240px;
        height: 180px;
        padding: 1.25rem;
    }
}

@media (max-width: 768px) {
    .projects-container {
        flex-direction: column;
        align-items: center;
        gap: 1.5rem;
    }
    
    .project-bubble {
        width: min(280px, 90vw);
        height: 160px;
    }
}

/* Stack connect content vertically and align to start */
#connect {
    flex-direction: column;
    align-items: stretch;
}

/* Remove indent for social links specifically in connect section */
#connect .social-links {
    margin-left: 0;
    margin-top: 0.5rem;
}

/* Two-column layout for connect area */
.connect-layout {
    display: grid;
    grid-template-columns: minmax(220px, 320px) 1fr;
    gap: clamp(1rem, 4vw, 2rem);
    width: 100%;
}

/* Contact form */
.contact-form {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.9rem;
}

.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.9rem;
}

.field label {
    display: block;
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 6px;
}

.field input,
.field textarea {
    width: 100%;
    padding: 10px 12px;
    font-size: 15px;
    color: var(--fg);
    background: color-mix(in srgb, var(--bg) 85%, transparent);
    border: 1px solid color-mix(in srgb, var(--fg) 18%, transparent);
    border-radius: 10px;
    outline: none;
    transition: border-color 160ms ease-out, box-shadow 160ms ease-out;
}

.field input:focus,
.field textarea:focus {
    border-color: color-mix(in srgb, var(--fg) 28%, transparent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--fg) 10%, transparent);
}

.submit-btn {
    justify-self: start;
    padding: 10px 16px;
    font-size: 15px;
    color: var(--fg);
    background: transparent;
    border: 1px solid currentColor;
    border-radius: 999px;
    cursor: pointer;
}

.submit-btn:hover,
.submit-btn:focus-visible {
    background: color-mix(in srgb, var(--fg) 8%, transparent);
}

@media (max-width: 720px) {
    .connect-layout {
        grid-template-columns: 1fr;
    }
    .field-row {
        grid-template-columns: 1fr;
    }
}

.typing {
    display: inline-block;
    white-space: normal;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    color: var(--fg);
}

.typing .letter {
    display: inline-block;
    transition: transform 150ms ease;
    will-change: transform;
}

.typing .letter:hover {
    transform: scale(1.35);
}

.typing.caret::after {
    content: '';
    display: inline-block;
    width: 2px;
    height: 0.9em;
    background: currentColor;
    margin-left: 2px;
    vertical-align: -0.1em;
    animation: blink 1s step-end infinite;
}

/* typing animation handled by JS now */

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

@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
    .typing { width: auto !important; border-right: 0 !important; }
    .typing .letter { transition: none !important; }
}

/* Theme toggle button */
.theme-toggle {
    position: fixed;
    bottom: 12px;
    left: 50%;
    transform: translate(-50%, 6px) scale(var(--sx, 1), var(--sy, 1));
    padding: 10px 14px;
    border-radius: 999px;
    border: 1px solid currentColor;
    background: transparent;
    color: var(--fg);
    font-size: 14px;
    cursor: pointer;
    opacity: 0;
    animation: fadeInUp 560ms ease-out 260ms forwards;
    transition: transform 160ms ease-out;
}

.theme-toggle:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

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

/* Fallbacks for browsers that don't support color-mix */
@supports not (color: color-mix(in srgb, black 50%, white 50%)) {
    [data-theme="light"] .nav-content,
    :root:not([data-theme="dark"]) .nav-content {
        background: rgba(0,0,0,0.06);
        border: 1px solid rgba(0,0,0,0.12);
        box-shadow: 0 6px 16px rgba(0,0,0,0.08);
    }
    [data-theme="dark"] .nav-content {
        background: rgba(255,255,255,0.06);
        border: 1px solid rgba(255,255,255,0.12);
        box-shadow: 0 6px 16px rgba(0,0,0,0.5);
    }
    [data-theme="light"] .nav-btn:hover,
    :root:not([data-theme="dark"]) .nav-btn:hover,
    [data-theme="light"] .nav-btn:focus-visible,
    :root:not([data-theme="dark"]) .nav-btn:focus-visible { background: rgba(0,0,0,0.08); }
    [data-theme="dark"] .nav-btn:hover,
    [data-theme="dark"] .nav-btn:focus-visible { background: rgba(255,255,255,0.08); }
}

