/* =========================================================================
   LAYER 1 — TOKENS
   Single source of truth: colors, fonts, layout, easing
   ========================================================================= */
:root {
    /* Colors */
    --bg: #050505;
    --fg: #f8f8f8;
    --muted: #888888;
    --accent: #00FFFF;
    --accent-rgb: 0, 255, 255;
    --fg-rgb: 248, 248, 248;
    --card-bg: rgba(255, 255, 255, 0.05);
    --card-border: rgba(255, 255, 255, 0.1);
    --border: rgba(255, 255, 255, 0.1);

    /* Legacy aliases (keeps JS / older selectors working) */
    --bg-color: var(--bg);
    --text-primary: var(--fg);
    --text-muted: var(--muted);
    --card-bg: rgba(255, 255, 255, 0.05);
    --card-border: rgba(255, 255, 255, 0.1);
    --text-primary-rgb: var(--fg-rgb);

    /* Typography */
    --f-head: 'Helvetica', sans-serif;
    --f-body: 'Inter', sans-serif;
    --font-heading: var(--f-head);
    --font-body: var(--f-body);

    /* Layout */
    --w-max: 1400px;
    --container-width: var(--w-max);
    --pad-section: clamp(80px, 12vw, 160px);
    --section-pad: var(--pad-section);
    --pad-x: 4vw;

    /* Easing */
    --ease-out: cubic-bezier(0.19, 1, 0.22, 1);
    --ease-spring: cubic-bezier(0.165, 0.84, 0.44, 1);
}

body.light-mode {
    --bg: #fcfaf7;
    --fg: #0a0a0a;
    --muted: #555555;
    --accent: #0a0a0a;
    --fg-rgb: 10, 10, 10;
    --card-bg: rgba(0, 0, 0, 0.05);
    --card-border: rgba(0, 0, 0, 0.1);
    --border: rgba(0, 0, 0, 0.1);
    --bg-color: #fcfaf7;
    --text-primary: #0a0a0a;
    --text-muted: #555555;
    --text-primary-rgb: 10, 10, 10;
}

/* =========================================================================
   LAYER 2 — BASE
   Reset, html/body, global elements, layout container
   ========================================================================= */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scrollbar-width: none;
}

html::-webkit-scrollbar {
    display: none;
}

html.lenis {
    height: auto;
}

.lenis.lenis-smooth {
    scroll-behavior: auto;
}

body {
    background-color: var(--bg);
    color: var(--fg);
    font-family: var(--f-body);
    font-size: 16px;
    line-height: 1.5;
    overflow-x: hidden;
    cursor: none;
    transition: background-color 0.8s ease, color 0.8s ease;
}

a {
    color: inherit;
    text-decoration: none;
    cursor: none;
}

ul {
    list-style: none;
}

.container {
    max-width: var(--w-max);
    margin: 0 auto;
    padding: 0 var(--pad-x);
}

/* Smooth scroll wrappers */
#particle-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    mix-blend-mode: difference;
    transition: opacity 0.8s ease;
}

body.light-mode #particle-bg {
    opacity: 0.1 !important;
    filter: grayscale(100%);
}

#smooth-wrapper {
    position: relative;
    z-index: 1;
}

#smooth-content {
    transition: opacity 0.4s ease-in-out;
}

/* State helpers */
.loading {
    overflow: hidden;
}

.lang-transitioning {
    opacity: 0 !important;
}

/* =========================================================================
   LAYER 3 — TYPOGRAPHY
   Shared text scale — applied via cascade on component/section selectors
   ========================================================================= */

/* --- Families --- */
.hero-title,
.section-title,
.large-text,
.huge-text,
.email-link,
.overlay-title,
.project-title,
.stat-num,
.loader-text,
.nav-logo a,
.nav-item,
.mobile-nav-item,
.ai-card-title,
.ai-chat-title,
.ai-chat-input-modern,
.ai-message-modern,
.skill-item span {
    font-family: var(--f-head);
}

/* --- Size scale --- */
.hero-title {
    font-size: clamp(4rem, 12vw, 15rem);
    line-height: 1;
}

.huge-text {
    font-size: clamp(5rem, 15vw, 15rem);
    line-height: 0.8;
}

.section-title {
    font-size: clamp(2rem, 5vw, 4rem);
    font-weight: 400;
}

.large-text {
    font-size: clamp(1.5rem, 3.5vw, 3rem);
    font-weight: 300;
    line-height: 1.2;
}

.email-link {
    font-size: clamp(2rem, 4vw, 4rem);
    font-weight: 300;
}

.stat-num {
    font-size: clamp(3rem, 5vw, 5rem);
    font-weight: 800;
    line-height: 1;
}

.hero-description,
.medium-text {
    font-size: clamp(1rem, 1.5vw, 1.25rem);
    color: var(--muted);
}

.hero-subtitle {
    font-size: 1.2rem;
    font-weight: 600;
}

.nav-logo a {
    font-size: 1.5rem;
    font-weight: 800;
}

.nav-item {
    font-size: 1.2rem;
    font-weight: 500;
}

.mobile-nav-item {
    font-size: clamp(2rem, 6vw, 3.5rem);
    font-weight: 700;
}

.ai-card-title {
    font-size: 1.5rem;
    font-weight: bold;
}

.ai-card-desc {
    font-size: 1.1rem;
    line-height: 1.6;
}

.ai-chat-title {
    font-size: 1.5rem;
    font-weight: 500;
}

.ai-chat-input-modern {
    font-size: 2.5rem;
    font-weight: 400;
    line-height: 1.1;
}

.ai-message-modern {
    font-size: clamp(1.2rem, 2vw, 1.25rem);
    line-height: 1.5;
}

.loader-text {
    font-size: 2vw;
}

.project-title {
    font-size: 2rem;
    font-weight: 400;
}

.overlay-title {
    font-size: 5vw;
    font-weight: 900;
}

.stat-label,
.copy,
.socials a,
.project-year {
    font-size: 0.9rem;
}

.scroll-text,
.project-link {
    font-size: 0.8rem;
}

.skill-item span {
    font-size: 1.1rem;
    font-weight: 600;
}

.section-title .num {
    font-size: clamp(1rem, 2vw, 1.5rem);
    font-weight: 300;
}

/* --- Text modifiers --- */
.hero-subtitle,
.stat-label,
.scroll-text,
.project-link,
.ask-ai-btn {
    text-transform: uppercase;
}

.nav-item,
.mobile-nav-item {
    text-transform: capitalize;
}

.overlay-title,
.huge-text {
    text-transform: uppercase;
}

.skill-item span {
    text-transform: uppercase;
}

.hero-title {
    letter-spacing: -0.04em;
}

.huge-text {
    letter-spacing: 0;
}

.section-title .text {
    letter-spacing: -0.02em;
}

.hero-subtitle,
.scroll-text {
    letter-spacing: 0.2em;
}

.nav-item,
.mobile-nav-item,
.stat-label {
    letter-spacing: 0.05em;
}

.skill-item span,
.project-link {
    letter-spacing: 0.1em;
}

.nav-logo a {
    letter-spacing: -0.05em;
}

/* --- Color assignments --- */
.hero-subtitle,
.section-title .num,
.stat-num,
.contact-nav {
    color: var(--accent);
}

.hero-description,
.medium-text,
.stat-label,
.project-year,
.project-desc,
.copy,
.ai-card-desc {
    color: var(--muted);
}

.nav-logo a,
.nav-item {
    color: #fff;
}

/* --- Outline/stroke text --- */
.outline-text {
    color: transparent;
    -webkit-text-stroke: 2px var(--fg);
}

/* =========================================================================
   LAYER 4 — EFFECTS
   Hover utilities + all @keyframes
   ========================================================================= */

/* --- Underline hover (shared pattern) --- */
.nav-item,
.socials a {
    position: relative;
    padding: 0.5rem 0;
}

.nav-item::after,
.socials a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 1px;
    background-color: currentColor;
    transform: scaleX(0);
    transform-origin: right;
    transition: transform 0.4s var(--ease-out);
}

.nav-item:hover::after,
.socials a:hover::after {
    transform: scaleX(1);
    transform-origin: left;
}

.contact-nav::after {
    background-color: var(--accent);
}

/* --- Card lift hover --- */
.card-modern {
    transition: transform 0.4s var(--ease-spring), border-color 0.4s, background-color 0.4s;
}

.card-modern:hover {
    transform: translateY(-8px);
    border-color: var(--accent);
    background-color: rgba(var(--fg-rgb), 0.03);
}

/* --- Link underline slide (email) --- */
.email-link .link-line {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: var(--fg);
    transform-origin: right;
    transition: transform 0.6s;
}

.email-link:hover .link-line {
    transform: scaleX(0);
    transform-origin: left;
}

.email-link:hover {
    color: var(--accent);
}

/* --- Generic hover accent color --- */
.mobile-nav-item:hover {
    color: var(--accent);
}

.project-link:hover {
    color: var(--fg);
    border-color: var(--fg);
}

.skill-item:hover .skill-icon {
    color: var(--accent);
    transform: scale(1.1);
}

/* --- Ask AI button hover --- */
.ask-ai-btn:hover {
    opacity: 1;
    border-color: var(--accent);
    background: rgba(var(--accent-rgb), 0.05);
    transform: translateY(-2px);
}

/* --- @keyframes --- */
@keyframes loadProg {
    to {
        width: 100%;
    }
}

@keyframes scrollLine {
    0% {
        transform: translateY(-100%);
    }

    50% {
        transform: translateY(0);
    }

    100% {
        transform: translateY(100%);
    }
}

@keyframes scrollMarquee {
    0% {
        transform: translateX(0);
    }

    100% {
        transform: translateX(-50%);
    }
}

@keyframes blinkCursor {
    50% {
        opacity: 0;
    }
}

/* =========================================================================
   LAYER 5 — COMPONENTS
   Self-contained, reusable UI blocks
   ========================================================================= */

/* --- Cursor --- */
.cursor {
    position: fixed;
    top: 0;
    left: 0;
    width: 10px;
    height: 10px;
    background-color: var(--accent);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 9999;
    mix-blend-mode: difference;
    transition: width 0.2s, height 0.2s;
}

.cursor-follower {
    position: fixed;
    top: 0;
    left: 0;
    width: 40px;
    height: 40px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 9998;
    transition: width 0.3s, height 0.3s;
}

/* --- Loader --- */
.loader-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: var(--bg);
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.loader-content {
    text-align: center;
}

.loader-text-wrapper {
    overflow: hidden;
    margin-bottom: 20px;
}

.loader-text {
    display: inline-block;
    text-transform: lowercase;
}

.loader-progress {
    width: 200px;
    height: 2px;
    background-color: var(--border);
    position: relative;
    margin: 0 auto;
    overflow: hidden;
}

.loader-progress::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0%;
    background-color: var(--accent);
    animation: loadProg 1.5s ease-in-out forwards;
}

/* --- Navbar --- */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    padding: 2.5rem var(--pad-x);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 1000;
    mix-blend-mode: difference;
}

.nav-links {
    display: flex;
    gap: 2rem;
}

/* Mobile nav button */
.mobile-menu-btn {
    display: none;
    flex-direction: column;
    gap: 6px;
    cursor: pointer;
}

.mobile-menu-btn span {
    width: 30px;
    height: 2px;
    background-color: var(--fg);
    transition: transform 0.3s;
}

.mobile-menu-btn.active span:first-child {
    transform: rotate(45deg) translate(3px, 3px);
}

.mobile-menu-btn.active span:last-child {
    transform: rotate(-45deg) translate(3px, -3px);
}

/* Mobile menu overlay */
.mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background-color: rgba(5, 5, 5, 0.97);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

.mobile-menu-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.mobile-nav-links {
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.mobile-nav-item {
    transition: color 0.3s ease;
    cursor: none;
}

/* --- Card (shared) --- */
.card-modern {
    background-color: var(--card-bg);
    border: 1px solid var(--card-border);
    padding: 3rem 2rem;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

/* --- Skill item (extends card-modern via JS) --- */
.skill-item {
    min-width: 280px;
    height: 320px;
    justify-content: center;
    text-align: center;
}

.skill-icon {
    width: 60px;
    height: 60px;
    color: var(--fg);
    transition: color 0.3s ease, transform 0.3s ease;
}

.skill-item span {
    display: block;
    margin-top: 1rem;
}

/* --- Section label style (stat-label / section num) --- */
.stat-label {
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.section-title .num {
    color: var(--accent);
}

.section-title .text {
    text-transform: capitalize;
}

/* --- Marquee --- */
.marquee-container {
    width: 100vw;
    overflow: hidden;
    position: relative;
    padding: 3rem 0;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    margin-top: 2rem;
}

.marquee {
    display: flex;
    width: max-content;
    white-space: nowrap;
}

.marquee-content {
    display: flex;
    align-items: center;
    gap: 3rem;
    padding: 0 1.5rem;
    animation: scrollMarquee 40s linear infinite;
}

/* --- AI Chat module --- */
.ai-chat-module {
    margin: 4rem 0;
    width: 100%;
    z-index: 10;
    position: relative;
    text-align: left;
}

.ai-chat-title {
    margin-bottom: 2rem;
    color: var(--fg);
}

.ai-chat-form-modern {
    display: flex;
    width: 100%;
    border-bottom: 1px solid var(--fg);
    padding-bottom: 1rem;
    margin-bottom: 1rem;
    transition: border-color 0.3s;
}

.ai-chat-input-modern {
    flex-grow: 1;
    background: transparent;
    border: none;
    color: var(--fg);
    padding: 0.25rem 0;
    resize: none;
    overflow: hidden;
    line-height: 1.1;
    min-height: calc(1.1em * 1.1);
}

.ai-chat-input-modern::placeholder {
    color: var(--fg);
    opacity: 0.5;
}

.ai-chat-input-modern:focus {
    outline: none;
}

.ai-response-modern {
    margin-top: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    width: 100%;
}

.ai-message-modern {
    position: relative;
    color: var(--fg);
    word-wrap: break-word;
    white-space: pre-wrap;
    padding-right: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px dashed rgba(var(--fg-rgb), 0.1);
    transition: opacity 0.3s ease;
}

.ai-message-modern:hover .ai-message-delete-modern {
    scale: 1.5;
}

.ai-message-modern.typing::after {
    content: '|';
    animation: blinkCursor 1s infinite step-start;
    color: var(--fg);
}

.ai-message-delete-modern {
    position: absolute;
    top: 0;
    right: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--fg);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    transition: all 0.3s ease;
}

.ai-message-delete-modern:hover {
    opacity: 1 !important;
    transform: scale(1.1);
}

/* --- Ask AI button --- */
.ask-ai-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--f-body);
    font-size: 0.85rem;
    color: var(--accent);
    background: transparent;
    border: 1px solid rgba(var(--fg-rgb), 0.1);
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 1rem;
    opacity: 0.7;
}

.ask-ai-btn svg {
    width: 14px;
    height: 14px;
}

body.light-mode .ask-ai-btn {
    border-color: rgba(0, 0, 0, 0.1);
}

.ai-chat-faqs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 1rem 0 0.5rem;
}

.ask-ai-btn.faq-starter {
    margin-top: 0;
    font-size: 0.78rem;
    opacity: 0.6;
    letter-spacing: 0.02em;
}

.ask-ai-btn.faq-starter:hover {
    opacity: 1;
    border-color: var(--accent);
    background: rgba(var(--accent-rgb), 0.05);
    transform: translateY(-2px);
}

/* =========================================================================
   LAYER 6 — SECTIONS
   Layout-only rules: padding, grid, positioning unique to each section
   ========================================================================= */

/* --- Shared section title --- */
.section-title {
    margin-bottom: 4rem;
    display: flex;
    align-items: baseline;
    gap: 1.5rem;
}

/* --- Hero --- */
.hero {
    height: 100vh;
    display: flex;
    align-items: center;
    position: relative;
}

.hero-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.hero-top {
    margin-bottom: 2rem;
    overflow: hidden;
}

.hero-title {
    font-weight: bold;
    margin-left: -1vw;
}

.title-line {
    overflow: hidden;
}

.title-line span {
    display: inline-block;
}

.hero-bottom {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding-right: 10%;
}

.hero-description {
    max-width: 450px;
}

.scroll-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.scroll-text {
    writing-mode: vertical-rl;
}

.scroll-line {
    width: 1px;
    height: 100px;
    background-color: var(--border);
    position: relative;
    overflow: hidden;
}

.scroll-line::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--accent);
    transform: translateY(-100%);
    animation: scrollLine 2s cubic-bezier(0.77, 0, 0.175, 1) infinite;
}

/* --- About --- */
.about {
    padding: var(--pad-section) 0;
}

.about-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 4rem;
}

.about-content {
    margin-left: auto;
}

.large-text {
    margin-bottom: 3rem;
}

.medium-text {
    max-width: 600px;
    margin-bottom: 5rem;
}

.word {
    display: inline-block;
    overflow: hidden;
    padding-bottom: 0.1em;
    margin-bottom: -0.1em;
}

.word>div {
    display: inline-block;
}

.stats-container {
    display: flex;
    gap: clamp(2rem, 6vw, 6rem);
    border-top: 1px solid var(--border);
    padding-top: 3rem;
}

.stat-item {
    display: flex;
    flex-direction: column;
}

.stat-num {
    margin-bottom: 0.5rem;
}

/* --- AI Section --- */
.ai {
    padding: 8rem 0;
}

.ai .section-header-simple {
    display: flex;
    flex-direction: column;
}

.ai-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-top: 4rem;
}

.ai-intro {
    margin-top: 2rem;
    margin-bottom: 3rem;
}

.ai-card-title {
    margin-bottom: 1rem;
}

/* --- Skills --- */
.skills {
    padding: var(--pad-section) 0;
    overflow: hidden;
}

/* --- Projects --- */
.projects {
    position: relative;
}

.placeholder-header {
    padding-top: var(--pad-section);
    padding-bottom: 2rem;
}

.horizontal-scroll-container {
    height: 100vh;
    display: flex;
    align-items: center;
    overflow: hidden;
}

.horizontal-scroll-wrapper {
    display: flex;
    width: max-content;
    padding: 0 var(--pad-x);
}

.project-panel {
    width: 60vw;
    height: 70vh;
    margin-right: 4vw;
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.project-inner {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.project-image-cont {
    flex: 1;
    position: relative;
    overflow: hidden;
    border-radius: 2rem;
}

.image-placeholder {
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.6s;
}

.project-panel:hover .image-placeholder {
    transform: scale(1.05);
}

.overlay-title {
    color: rgba(255, 255, 255, 0.05);
}

.project-info {
    padding: 2rem 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.project-desc {
    max-width: 80%;
}

.project-link {
    margin-top: auto;
    align-self: flex-start;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--accent);
    color: var(--accent);
    transition: color 0.3s, border-color 0.3s;
}

/* --- Contact / Footer --- */
.contact {
    min-height: 100vh;
    display: flex;
    align-items: flex-end;
    padding: 100px 0;
}

.contact-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.huge-text {
    font-weight: 900;
    text-align: center;
    margin-bottom: 4rem;
}

.email-link {
    position: relative;
    padding-bottom: 10px;
    margin-bottom: 100px;
}

.footer-bottom {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 3rem;
    border-top: 1px solid var(--border);
}

.socials {
    display: flex;
    gap: 2rem;
}

/* =========================================================================
   RESPONSIVE
   ========================================================================= */
@media (max-width: 1024px) {
    .project-panel {
        width: 80vw;
    }

    .about-grid {
        gap: 2rem;
    }
}

@media (max-width: 768px) {
    .nav-links {
        display: none;
    }

    .mobile-menu-btn {
        display: flex;
    }

    .stats-container {
        flex-direction: column;
        gap: 2rem;
    }

    .project-panel {
        width: 90vw;
    }

    .footer-bottom {
        flex-direction: column;
        gap: 2rem;
        text-align: center;
    }
}