:root {
    --cursor-size: 20px;
    --color-obsidian: #050505;
    --color-bone: #F2F2F2;
    --color-accent: #EBEBEB;
    --color-primary: #FF4D2E;
    --color-surface: #F3F4F4;
    --color-text-muted: rgba(255, 255, 255, 0.6);
    --radius-xl: 32px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--color-obsidian);
    color: var(--color-bone);
    margin: 0;
    overflow-x: hidden;
    cursor: none;
    font-family: 'Inter', sans-serif;
}

html.lenis {
    height: auto;
}

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

.lenis.lenis-smooth [data-lenis-prevent] {
    overscroll-behavior: contain;
}

.lenis.lenis-stopped {
    overflow: hidden;
}

.lenis.lenis-scrolling iframe {
    pointer-events: none;
}

#webgl-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -2;
    pointer-events: none;
    background-image: url('./images/01back.jpg');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
}

@media (max-width: 1024px) {
    #webgl-container {
        background-attachment: scroll;
    }
}

#webgl-container::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(5, 5, 5, 0.6);
    z-index: 1;
}

.noise-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 50;
    opacity: 0.04;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
}

.ref-lines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: -1;
    display: flex;
    justify-content: space-between;
    padding: 0 5vw;
}

.ref-line {
    width: 1px;
    height: 100%;
    background: transparent;
}

.custom-cursor {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--cursor-size);
    height: var(--cursor-size);
    border-radius: 50%;
    background-color: white;
    pointer-events: none;
    z-index: 9999;
    mix-blend-mode: difference;
    transform: translate(-50%, -50%);
    transition: width 0.3s cubic-bezier(0.25, 1, 0.5, 1), height 0.3s cubic-bezier(0.25, 1, 0.5, 1);
}

.custom-cursor.active {
    width: 60px;
    height: 60px;
}

@media (hover: none) and (pointer: coarse) {
    .custom-cursor {
        display: none !important;
    }
    body {
        cursor: auto;
    }
}

.split-char {
    display: inline-block;
    overflow: hidden;
}

.split-char span {
    display: inline-block;
    transform: translateY(100%);
}

#smooth-content {
    will-change: transform, filter;
    transition: filter 0.1s linear;
}

@media (hover: none) and (pointer: coarse) {
    #smooth-content {
        will-change: auto;
        transition: none;
    }
}

.img-wrap {
    overflow: hidden;
    position: relative;
}

.img-wrap img {
    transition: transform 1s cubic-bezier(0.19, 1, 0.22, 1);
    -webkit-user-drag: none;
    user-drag: none;
    -webkit-user-select: none;
    user-select: none;
    pointer-events: none;
    -webkit-touch-callout: none;
}

.img-wrap::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 1;
}

.img-wrap:hover img {
    transform: scale(1.05);
}

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

.service-modal {
    position: fixed;
    inset: 0;
    min-height: 100vh;
    z-index: 60;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 2rem 1rem;
    background: rgba(0, 0, 0, 0.72);
    touch-action: auto;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.service-modal.open {
    display: flex;
}

.service-modal-card {
    width: 100%;
    max-width: 1120px;
    max-height: calc(100vh - 4rem);
    overflow: hidden;
    border-radius: var(--radius-xl);
    background: white;
    box-shadow: 0 36px 120px rgba(0, 0, 0, 0.18);
    display: flex;
    flex-direction: column;
    margin: auto;
}

.service-modal-body {
    flex: 1 1 auto;
    min-height: 0;
    max-height: calc(100vh - 5.5rem);
    overflow-y: auto;
    overflow-x: hidden;
    touch-action: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.service-modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 2.75rem;
    height: 2.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    background: rgba(255, 255, 255, 0.95);
    color: #050505;
    cursor: pointer;
}

.service-modal-close:hover {
    background: rgba(255, 255, 255, 1);
}

.glass-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(30px) saturate(220%);
    -webkit-backdrop-filter: blur(30px) saturate(220%);
    border: 1px solid rgba(255, 255, 255, 0.24);
    box-shadow: 0 10px 48px rgba(0, 0, 0, 0.45), inset 0 1.5px 0 rgba(255, 255, 255, 0.18);
    color: rgba(255, 255, 255, 0.95);
    text-decoration: none;
    transition: background 0.3s ease, box-shadow 0.3s ease, transform 0.25s ease;
}

.glass-button:hover {
    background: rgba(255, 255, 255, 0.22);
    box-shadow: 0 16px 56px rgba(0, 0, 0, 0.55), inset 0 1.5px 0 rgba(255, 255, 255, 0.28);
}

.social-link {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(22px) saturate(150%);
    -webkit-backdrop-filter: blur(22px) saturate(200%);
    border: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow: 0 5px 24px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    transition: background 0.3s ease, transform 0.25s ease;
}

.social-link:hover {
    background: rgba(255, 255, 255, 0.18);
}

.menu-button {
    width: 3rem;
    height: 3rem;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: var(--color-primary);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    transition: transform 0.25s ease;
}

.menu-button:hover {
    transform: scale(1.05);
}

.hero-desc {
    opacity: 0;
}

@media (max-width: 768px) {
    .glass-button {
        width: auto;
    }
}

/* ── Project Cards ────────────────────────────────────── */
.project-card {
    cursor: pointer;
    position: relative;
}

.project-card-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(5,5,5,0.9) 0%, rgba(5,5,5,0.15) 55%, transparent 100%);
    opacity: 0;
    transition: opacity 0.45s cubic-bezier(0.19, 1, 0.22, 1);
    display: flex;
    align-items: flex-end;
    padding: 18px;
    border-radius: inherit;
    pointer-events: none;
}

.project-card:hover .project-card-overlay {
    opacity: 1;
}

.project-card-name {
    font-family: 'Noto Sans TC', sans-serif;
    font-size: 0.95rem;
    font-weight: 900;
    color: white;
    letter-spacing: 0.01em;
}

@media (min-width: 768px) {
    .project-card-name { font-size: 1.1rem; }
}

/* ── Image Lightbox ─────────────────────────────────────── */
.img-lightbox {
    position: fixed;
    inset: 0;
    z-index: 70;
    background: rgba(5, 5, 5, 0.96);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.img-lightbox.open {
    display: flex;
}

.img-lightbox img {
    width: auto;
    height: auto;
    max-width: min(1080px, calc(100vw - 40px));
    max-height: calc(100vh - 40px);
    object-fit: contain;
    border-radius: 16px;
    -webkit-user-drag: none;
    user-drag: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    pointer-events: none;
}

.img-lightbox-close {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.14);
    color: rgba(255,255,255,0.8);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    line-height: 1;
    transition: background 0.2s;
    z-index: 71;
}

.img-lightbox-close:hover {
    background: rgba(255,255,255,0.15);
    color: white;
}

/* ── Project Modal ──────────────────────────────────────── */
.project-modal {
    position: fixed;
    inset: 0;
    z-index: 60;
    background: rgba(5, 5, 5, 0.97);
    display: none;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.project-modal.open {
    display: block;
}

.project-modal-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 72px 24px 80px;
}

@media (min-width: 768px) {
    .project-modal-inner { padding: 80px 48px 100px; }
}

.project-modal-close {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.14);
    color: rgba(255,255,255,0.8);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    line-height: 1;
    transition: background 0.2s, color 0.2s;
    z-index: 61;
}

.project-modal-close:hover {
    background: rgba(255,255,255,0.15);
    color: white;
}

.project-modal-header {
    margin-bottom: 40px;
    padding-bottom: 36px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.project-modal-title {
    font-family: 'Noto Sans TC', sans-serif;
    font-size: clamp(2rem, 6vw, 4rem);
    font-weight: 900;
    color: white;
    margin: 0 0 14px;
    line-height: 1.1;
    letter-spacing: -0.01em;
}

.project-modal-desc {
    color: rgba(255,255,255,0.48);
    font-size: 0.9rem;
    line-height: 1.8;
    max-width: 560px;
    margin: 0;
}

.project-modal-images {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

@media (min-width: 768px) {
    .project-modal-images {
        gap: 16px;
    }
}

.project-modal-img-wrap {
    cursor: zoom-in;
    overflow: hidden;
    border-radius: 12px;
}

@media (min-width: 768px) {
    .project-modal-img-wrap { border-radius: 20px; }
}

.project-modal-img {
    width: 100%;
    aspect-ratio: 4/5;
    object-fit: cover;
    border-radius: inherit;
    display: block;
    -webkit-user-drag: none;
    user-drag: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    pointer-events: none;
}
