/* ========== Components ========== */

/* Glitch Effect */
.glitch {
    position: relative;
    color: var(--text-primary);
}

.glitch::before,
.glitch::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--primary-bg);
}

.glitch::before {
    left: 2px;
    text-shadow: -1px 0 #ff0033;
    clip: rect(24px, 550px, 90px, 0);
    animation: glitch-anim-2 3s infinite linear alternate-reverse;
}

.glitch::after {
    left: -2px;
    text-shadow: -1px 0 #00ccff;
    clip: rect(85px, 550px, 140px, 0);
    animation: glitch-anim 2.5s infinite linear alternate-reverse;
}

@keyframes glitch-anim {
    0% { clip: rect(14px, 9999px, 86px, 0); }
    20% { clip: rect(98px, 9999px, 8px, 0); }
    40% { clip: rect(4px, 9999px, 115px, 0); }
    60% { clip: rect(62px, 9999px, 73px, 0); }
    80% { clip: rect(31px, 9999px, 148px, 0); }
    100% { clip: rect(104px, 9999px, 3px, 0); }
}

@keyframes glitch-anim-2 {
    0% { clip: rect(65px, 9999px, 110px, 0); }
    20% { clip: rect(96px, 9999px, 20px, 0); }
    40% { clip: rect(2px, 9999px, 143px, 0); }
    60% { clip: rect(54px, 9999px, 44px, 0); }
    80% { clip: rect(27px, 9999px, 137px, 0); }
    100% { clip: rect(9px, 9999px, 93px, 0); }
}

/* Hero Section */
.hero {
    padding: 120px 60px;
    min-height: 800px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
}

.hero-content {
    max-width: 800px;
    position: relative;
    z-index: 2;
}

.hero-modules {
    font-family: monospace;
    margin-top: 20px;
    color: #666;
    min-height: 3.2em;
}

.hero-modules__cursor {
    color: var(--accent);
    font-weight: bold;
    animation: heroCursorBlink 1s step-end infinite;
}

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

.status-badge {
    display: inline-block;
    padding: 5px 15px;
    border: 1px solid var(--text-primary);
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 20px;
    background: rgba(255, 255, 255, 0.8);
}

:lang(zh-Hans) .status-badge {
    text-transform: none;
    letter-spacing: 0.04em;
}

.status-badge span {
    color: var(--accent);
    font-weight: bold;
}

h1 {
    font-family: 'MiSans-Bold';
    font-size: 120px;
    line-height: 0.9;
    text-transform: uppercase;
    margin-bottom: 40px;
    color: var(--text-primary);
}

.hero h1.glitch {
    font-size: clamp(2.75rem, 11vw, 120px);
    text-transform: none;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.hero p {
    font-size: 20px;
    line-height: 1.6;
    max-width: 600px;
    margin-bottom: 60px;
    border-left: 4px solid var(--accent);
    padding-left: 20px;
}

/* Decorative Code & Corners */
.corner-tl, .corner-tr, .corner-bl, .corner-br {
    position: absolute;
    width: 40px;
    height: 40px;
    border: 2px solid var(--text-primary);
    z-index: 1;
}

.corner-tl { top: 40px; left: 40px; border-right: none; border-bottom: none; }
.corner-tr { top: 40px; right: 40px; border-left: none; border-bottom: none; }
.corner-bl { bottom: 40px; left: 40px; border-right: none; border-top: none; }
.corner-br { bottom: 40px; right: 40px; border-left: none; border-top: none; }

.bg-code {
    position: absolute;
    font-family: monospace;
    color: var(--code-color);
    font-size: 14px;
    line-height: 1.4;
    user-select: none;
    z-index: 0;
}

.bg-code.top-right { top: 100px; right: 100px; text-align: right; }
.bg-code.bottom-left { bottom: 100px; left: 100px; }

/* Decorative code marquee (hero corners) */
.bg-code--scroll .bg-code-scroll__viewport {
    overflow: hidden;
    max-height: 280px;
    width: min(100%, 420px);
}

.bg-code.top-right.bg-code--scroll .bg-code-scroll__viewport {
    margin-left: auto;
}

.bg-code.bottom-left.bg-code--scroll .bg-code-scroll__viewport {
    width: min(100%, 400px);
}

.bg-code-scroll__track {
    display: flex;
    flex-direction: column;
    animation: bgCodeScrollUp 8s linear infinite;
    will-change: transform;
}

.bg-code-scroll__track--slow {
    animation-duration: 16s;
}

.bg-code-scroll__panel {
    flex-shrink: 0;
}

@keyframes bgCodeScrollUp {
    from { transform: translateY(0); }
    to { transform: translateY(-50%); }
}

@media (prefers-reduced-motion: reduce) {
    .hero-modules__cursor {
        animation: none;
    }

    .bg-code-scroll__track {
        animation: none;
    }

    .bg-code-scroll__panel[aria-hidden="true"] {
        display: none;
    }
}

/* Math Formula - decorative */
.math-formula {
    position: absolute;
    font-family: "Times New Roman", serif;
    font-style: italic;
    opacity: 0.1;
    font-size: 24px;
    z-index: 0;
}

.math-formula--hero-1 { top: 20%; left: 60%; font-size: 40px; }
.math-formula--hero-2 { bottom: 25%; right: 20%; font-size: 32px; }
.math-formula--work { color: rgba(255, 255, 255, 0.05); top: 10%; right: 5%; }
.math-formula--contact { bottom: 5%; left: 5%; }

/* Section Header */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 80px;
    border-bottom: 1px solid #333;
    padding-bottom: 20px;
}

.section-header--light {
    border-color: #ddd;
}

.section-title {
    font-family: 'MiSans-Bold';
    font-size: clamp(2rem, 7vw, 60px);
    line-height: 1.05;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.section-title--dark {
    color: var(--text-primary);
}

.section-meta {
    font-family: monospace;
    color: #666;
    text-align: right;
}

/* Work Section */
.work-section {
    background-color: var(--secondary-bg);
    color: var(--text-secondary);
    padding: 100px 60px;
    position: relative;
}

.work-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 40px;
}

.project-card {
    border: 1px solid #333;
    background: #1a1a1a;
    height: 500px;
    position: relative;
    transition: 0.3s;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.project-card:hover {
    border-color: var(--accent);
    transform: translateY(-5px);
}

.card-image {
    height: 60%;
    background-color: #222;
    position: relative;
    overflow: hidden;
    border-bottom: 1px solid #333;
}

.card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: grayscale(100%);
    transition: 0.5s;
}

.project-card:hover .card-image img {
    filter: grayscale(0%);
}

.project-card-link {
    display: block;
    color: inherit;
    text-decoration: none;
    outline: none;
}

.project-card-link:focus-visible .project-card {
    outline: 2px solid var(--accent);
    outline-offset: 4px;
}

.project-card-link .project-card {
    height: 100%;
}

/* Case detail page */
.case-detail {
    padding-top: 48px;
}

.case-detail__toolbar {
    margin-bottom: 40px;
}

.case-back {
    display: inline-flex;
    align-items: center;
    font-family: monospace;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    text-decoration: none;
    border: 1px solid rgba(248, 248, 248, 0.35);
    padding: 12px 20px;
    transition: color 0.3s, border-color 0.3s;
}

.case-back:hover {
    color: var(--accent);
    border-color: var(--accent);
}

.case-detail__header.section-header {
    align-items: flex-end;
}

.case-detail__record {
    font-family: monospace;
    font-size: 12px;
    color: var(--accent);
    margin-bottom: 12px;
    letter-spacing: 0.05em;
}

.case-detail__title {
    margin-bottom: 16px;
}

.case-detail__desc {
    font-size: 16px;
    line-height: 1.6;
    color: #888;
    max-width: 720px;
}

.case-detail__hero {
    margin-bottom: 48px;
    border: 1px solid #333;
    background: #222;
    overflow: hidden;
}

.case-detail__hero img {
    width: 100%;
    height: auto;
    display: block;
    vertical-align: middle;
    filter: grayscale(40%);
    transition: filter 0.5s;
}

.case-detail__hero:hover img {
    filter: grayscale(0%);
}

.case-detail__body {
    font-size: 16px;
    line-height: 1.75;
    color: #aaa;
    max-width: 800px;
    margin-bottom: 40px;
}

.case-detail__body p + p {
    margin-top: 1.25em;
}

.case-detail__tech {
    margin-bottom: 60px;
}

.card-overlay {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--accent);
    color: white;
    padding: 2px 8px;
    font-size: 10px;
    font-family: monospace;
}

.card-content {
    padding: 30px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 40%;
}

.project-title {
    font-size: 24px;
    font-family: 'AlibabaSans-Medium';
    margin-bottom: 10px;
    color: var(--text-secondary);
}

.project-desc {
    font-size: 14px;
    color: #888;
    margin-bottom: 20px;
    line-height: 1.5;
}

.project-tech {
    display: flex;
    gap: 10px;
    font-family: monospace;
    font-size: 12px;
    color: #666;
}

.project-tech span {
    border: 1px solid #444;
    padding: 2px 6px;
}

/* Contact Section */
.contact-section {
    padding: 100px 60px;
    background-color: var(--primary-bg);
    position: relative;
    min-height: 600px;
}

.contact-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 80px;
}

.contact-info {
    position: relative;
}

.contact-item {
    margin-bottom: 40px;
    border-left: 2px solid #ccc;
    padding-left: 20px;
    transition: 0.3s;
}

.contact-item:hover {
    border-left-color: var(--accent);
}

.contact-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: #666;
    margin-bottom: 5px;
    display: block;
}

.contact-value {
    font-size: 28px;
    font-family: 'MiSans-Bold';
    color: var(--text-primary);
    text-decoration: none;
}

.contact-social {
    display: flex;
    gap: 20px;
    margin-top: 10px;
}

.contact-social .contact-value {
    font-size: 16px;
    border: 1px solid black;
    padding: 10px 20px;
}

.contact-disclaimer {
    margin-top: 60px;
    font-family: monospace;
    color: #666;
    font-size: 12px;
    line-height: 2;
}

/* Form */
.form-container {
    background: white;
    border: 1px solid #000;
    padding: 40px;
    position: relative;
}

.form-container::before {
    content: '';
    position: absolute;
    top: -5px;
    left: -5px;
    width: 20px;
    height: 20px;
    border-top: 2px solid var(--accent);
    border-left: 2px solid var(--accent);
}

.form-container::after {
    content: '';
    position: absolute;
    bottom: -5px;
    right: -5px;
    width: 20px;
    height: 20px;
    border-bottom: 2px solid var(--accent);
    border-right: 2px solid var(--accent);
}

.input-group {
    margin-bottom: 30px;
    position: relative;
}

.input-group label {
    display: block;
    margin-bottom: 10px;
    font-family: monospace;
    font-size: 12px;
    text-transform: uppercase;
}

.input-group input,
.input-group textarea {
    width: 100%;
    border: none;
    border-bottom: 1px solid #000;
    background: transparent;
    padding: 10px 0;
    font-family: 'MiSans-Regular';
    font-size: 16px;
    outline: none;
}

.input-group input:focus,
.input-group textarea:focus {
    border-bottom-color: var(--accent);
}

.submit-btn {
    background: black;
    color: white;
    border: none;
    padding: 15px 40px;
    font-family: 'AlibabaSans-Medium';
    text-transform: uppercase;
    letter-spacing: 2px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: 0.3s;
}

.submit-btn:hover {
    background: var(--accent);
}

/* Decorative Elements */
.decor-line {
    width: 100%;
    height: 1px;
    background: #ddd;
    margin: 20px 0;
    position: relative;
}

.decor-line::after {
    content: '';
    position: absolute;
    width: 50px;
    height: 3px;
    background: var(--accent);
    left: 20%;
    top: -1px;
}

/* --- Responsive --- */
@media (max-width: 1280px) {
    .hero {
        padding: 100px 40px;
    }

    .work-section,
    .contact-section {
        padding: 80px 40px;
    }
}

@media (max-width: 900px) {
    .work-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 28px;
    }
}

@media (max-width: 768px) {
    .hero {
        padding: 72px 20px 80px;
        min-height: auto;
    }

    .hero p {
        font-size: clamp(16px, 4.2vw, 20px);
    }

    .corner-tl, .corner-tr, .corner-bl, .corner-br {
        width: 28px;
        height: 28px;
    }

    .corner-tl { top: 20px; left: 16px; }
    .corner-tr { top: 20px; right: 16px; }
    .corner-bl { bottom: 20px; left: 16px; }
    .corner-br { bottom: 20px; right: 16px; }

    .bg-code {
        font-size: 11px;
    }

    .bg-code.top-right {
        top: 72px;
        right: 12px;
        max-width: 42%;
    }

    .bg-code.bottom-left {
        bottom: 80px;
        left: 12px;
        max-width: 48%;
    }

    .bg-code--scroll .bg-code-scroll__viewport {
        max-height: 200px;
    }

    .math-formula--hero-1,
    .math-formula--hero-2 {
        font-size: clamp(18px, 4vw, 28px);
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
        margin-bottom: 48px;
    }

    .section-meta {
        text-align: left;
    }

    .work-section,
    .contact-section {
        padding: 64px 20px;
    }

    .work-grid {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .project-card {
        height: auto;
        min-height: 440px;
    }

    .contact-grid {
        grid-template-columns: 1fr;
        gap: 48px;
    }

    .contact-value {
        font-size: clamp(1.25rem, 5vw, 28px);
    }

    .contact-value--email {
        word-break: break-word;
        overflow-wrap: anywhere;
    }

    .contact-social .contact-value {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .form-container {
        padding: 28px 20px;
    }

    .input-group input,
    .input-group textarea {
        font-size: 16px;
    }

    .submit-btn {
        min-height: 48px;
        padding: 14px 32px;
        width: 100%;
    }

    .case-detail__header .section-meta {
        text-align: left;
    }

    .case-back {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .project-title {
        font-size: 20px;
    }

    .card-content {
        padding: 20px;
    }
}
