:root {
    --bg-color: #eeeeee;
    --text-color: #1a1a1a;
    --accent-color: #000000;
}

* {
    box-sizing: border-box;
}

/* 在桌面设备上隐藏默认光标 */
@media (min-width: 769px) {
    * {
        cursor: none;
    }
}

body,
html {
    margin: 0;
    padding: 0;
    width: 100%;
    font-family: 'Patrick Hand', cursive;
    background-color: var(--bg-color);
    color: var(--text-color);
    overflow-x: hidden;
}

/* 背景 Canvas */
#bg-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
}

/* 动态纹理 Canvas */
#grunge-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    /* Behind z-index: 1 content, but above -1 bg */
    pointer-events: none;
    opacity: 0.5;
    mix-blend-mode: multiply;
}

/* Avatar Card Styles */
.avatar-card {
    padding: 0 !important;
    overflow: hidden;
    background-color: #fff;
}

.avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* 自定义光标 */
#cursor {
    position: fixed;
    top: 0;
    left: 0;
    width: 20px;
    height: 20px;
    border: 2px solid #fff;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 9999;
    transition: width 0.2s, height 0.2s, background-color 0.2s;
    mix-blend-mode: difference;
}

/* 在手机模式下隐藏自定义光标 */
@media (max-width: 768px) {
    #cursor {
        display: none;
    }
}

#cursor.active {
    width: 10px;
    height: 10px;
    background-color: #fff;
}

/* 布局 */
main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
    position: relative;
    z-index: 1;
}

section {
    margin-bottom: 4rem;
    padding: 3rem 0;
}

/* Hero 区域 */
#hero {
    height: 80vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    position: relative;
    /* Added for scroll indicator positioning */
}

.logo-container {
    margin-bottom: 2rem;
    /* Increased spacing (was 0rem) */
    width: 100%;
    display: flex;
    justify-content: center;
}

.tagline {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    /* Clean Code style */
    font-size: 1.5rem;
    margin: 0 auto;
    min-height: 2.5rem;
    letter-spacing: 3px;
    /* Minimalist Style */
    background-color: transparent;
    color: #333;
    /* Charcoal */
    padding: 0;
    border-radius: 0;
    display: inline-block;
    box-shadow: none;
    border: none;
    font-weight: 500;
}

.blinking-cursor {
    font-weight: bold;
    font-size: 1.5rem;
    color: #333;
    /* Match text */
    animation: blink 1s step-end infinite;
    margin-left: 2px;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

/* 作品集区域 */
h2 {
    font-size: 2.5rem;
    border-bottom: 2px dashed #ccc;
    /* 降级回退样式 */
    display: inline-block;
    margin-bottom: 2rem;
}

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

.card {
    background-color: #ffffff;
    border: 1px solid #eaeaea;
    border-radius: 16px;
    /* Slightly more rounded */
    padding: 1.5rem;
    position: relative;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
    text-decoration: none;
    /* For link cards */
    display: flex;
    flex-direction: row;
    /* Changed to row */
    align-items: center;
    /* Vertically center */
    gap: 1.5rem;
    /* Space between icon and text */
    color: inherit;
    overflow: hidden;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 20px rgba(0, 0, 0, 0.1);
    border-color: #16a34a;
    /* Green highlight on hover */
}

.card-icon {
    margin-bottom: 0;
    /* Removed bottom margin */
    color: #333;
    flex-shrink: 0;
    /* Prevent icon from shrinking */
    width: 80px;
    /* Fixed width for the icon container */
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-content {
    flex-grow: 1;
    /* Allow content to take remaining space */
    text-align: left;
}

.card-content h3 {
    margin-top: 0;
    margin-bottom: 0.5rem;
    font-size: 1.25rem;
    /* Adjusted font size */
    font-weight: 700;
}

.card-content p {
    margin: 0;
    color: #666;
    line-height: 1.5;
    font-size: 0.95rem;
}

/* .card h3 rule removed as it's covered in .card-content h3 */

/* Header Styles */
#site-header {
    position: fixed;
    top: 10px;
    left: 40px;
    z-index: 100;
    /* Above main content, below grunge overlay */
    /* Above main content, below grunge overlay */
    pointer-events: auto;
}

@media (max-width: 768px) {
    #site-header {
        left: 20px;
        /* Reduced from 40px for mobile */
    }
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    /* Reduced gap from 15px */
    opacity: 1;
    /* Changed from 0.9 to 1 to avoid confusion with scrolling opacity */
    transition: opacity 0.3s;
}

.logo:hover {
    opacity: 1;
}

.logo img {
    display: block;
    /* Removes inline spacing */
    width: 32px;
    height: 32px;
    /* Hand-drawn feel */
    filter: drop-shadow(1px 1px 0px rgba(0, 0, 0, 0.1));

    /* Initial state: Hidden until scrolled */
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.4s ease-out;
    /* Bouncy effect removed to prevent overshoot */
    visibility: hidden;
    /* Prevent clicking when hidden */
}

/* Visibility state to be toggled via JS */
.logo.visible img {
    opacity: 1;
    transform: translateY(0);
    visibility: visible;
}


.site-name {
    font-size: 1.8rem;
    font-weight: bold;
    color: var(--text-color);
    letter-spacing: 1px;
    line-height: 1;
    /* Ensure vertical centering matches image */
    padding-bottom: 3px;
    /* Lift text slightly to counteract lowercase sinking */
    /* padding-top removed */

    /* Initial state: Hidden until scrolled (sync with logo img) */
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.4s ease-out;
    visibility: hidden;
}

/* Visibility state to be toggled via JS */
.logo.visible .site-name {
    opacity: 1;
    transform: translateY(0);
    visibility: visible;
}

/* Responsive Design */
@media (max-width: 768px) {
    .tagline {
        font-size: 1rem;
    }

    .blinking-cursor {
        font-size: 1rem;
    }
}

/* Scroll Indicator */
.scroll-indicator {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0.8;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

.scroll-indicator span {
    display: block;
    width: 20px;
    height: 20px;
    border-bottom: 2px solid #333;
    border-right: 2px solid #333;
    transform: rotate(45deg);
    margin: -10px;
    animation: scroll-animate 2s infinite;
}

.scroll-indicator span:nth-child(2) {
    animation-delay: -0.2s;
}

.scroll-indicator span:nth-child(3) {
    animation-delay: -0.4s;
}

@keyframes scroll-animate {
    0% {
        opacity: 0;
        transform: rotate(45deg) translate(-20px, -20px);
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0;
        transform: rotate(45deg) translate(20px, 20px);
    }
}

/* Feature Section (Redesign - Open Layout) */
.feature-section {
    display: flex;
    align-items: center;
    /* Vertically center content */
    justify-content: space-between;
    gap: 8rem;
    /* Increased gap to push content to sides */
    padding: 4rem 0;
    /* Significant vertical spacing, no horizontal padding */
    /* Removed background, border, shadow, radius for open layout */
    margin-bottom: 0;
    position: relative;
    overflow: visible;
    /* Allow visual elements to pop out if needed */
}



/* Removed hover effects on the section itself */
.feature-section:hover {
    transform: none;
    box-shadow: none;
}

.feature-content {
    flex: 1;
    max-width: 40%;
    /* Reduced width for text content */
    z-index: 2;
}

.feature-tagline {
    font-family: 'Consolas', monospace;
    font-size: 1rem;
    color: #16a34a;
    text-transform: uppercase;
    letter-spacing: 3px;
    margin-bottom: 1.5rem;
    display: block;
    font-weight: 600;
}

/* Header container for Icon + Title */
.feature-header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.feature-icon {
    width: 80px;
    height: 80px;
    flex-shrink: 0;
    /* Optional: Add a subtle background or shadow to the icon container */
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.1));
}

.feature-title {
    font-size: 3.5rem;
    /* Larger title */
    font-weight: 800;
    margin: 0;
    /* Margin handled by .feature-header */
    line-height: 1.1;
    color: #1a1a1a;
    letter-spacing: -1px;
}

.feature-description {
    font-size: 1.25rem;
    /* Larger description */
    line-height: 1.8;
    color: #444;
    margin-bottom: 3rem;
    font-weight: 400;
}

.feature-list {
    list-style: none;
    padding: 0;
    margin: 0 0 3rem 0;
}

.feature-list li {
    margin-bottom: 1rem;
    padding-left: 2rem;
    position: relative;
    font-size: 1.1rem;
    color: #333;
    font-weight: 500;
}

.feature-list li::before {
    content: "→";
    /* Arrow instead of dot */
    color: #16a34a;
    font-weight: bold;
    font-size: 1.5rem;
    position: absolute;
    left: 0;
    top: -2px;
}

.feature-cta {
    display: inline-block;
    padding: 1.2rem 3rem;
    /* Larger button */
    background-color: #1a1a1a;
    /* Dark button for contrast */
    color: #fff;
    font-size: 1.2rem;
    font-weight: 600;
    border-radius: 50px;
    text-decoration: none;
    transition: all 0.3s ease;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

.feature-cta:hover {
    background-color: #000;
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.25);
}

.feature-visual {
    flex: 1.5;
    /* Give more space to visual */
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    height: 420px;
    /* Reduced height for landscape */
    /* Removed background/border for cleaner look */
}

/* Content within visual area */
.feature-visual-content {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.5s ease;
}

.feature-section:hover .feature-visual-content {
    transform: scale(1.02);
    /* Subtle scale on hover */
}

/* RakuLife Fanned-Out Screenshot Collage (Landscape) */
.rakulife-collage {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    perspective: 1000px;
}

.collage-slice {
    position: absolute;
    width: 70%;
    /* Wider for landscape */
    aspect-ratio: 16/10;
    /* Landscape aspect ratio */
    height: auto;
    /* Let aspect ratio drive height */
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.18);
    border: 4px solid #fff;
    /* Thicker border for photo look */
    transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1), box-shadow 0.4s ease;
    background: #fff;
    /* Ensure z-index transition is instant on hover, delayed on leave to prevent flickering */
    transition-delay: 0s;
    will-change: transform;
}

.collage-slice img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* Ensure image fills the card */
    object-position: center;
    display: block;
}

/* Fanned out: left, center, right with tilt */
/* Adjusted spread to be wider so hover targets are larger */
.slice-1 {
    z-index: 1;
    transform: translateX(-35%) translateY(10%) rotate(-8deg);
    transform-origin: center bottom;
}

.slice-2 {
    z-index: 3;
    transform: translateX(0%) translateY(0%) rotate(0deg) scale(1.05);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.22);
    transform-origin: center bottom;
}

.slice-3 {
    z-index: 2;
    transform: translateX(35%) translateY(10%) rotate(8deg);
    transform-origin: center bottom;
}


/* Hover: bring slice to front */
/* Specifically override transform for each slice to MAINTAIN position */
.slice-1:hover {
    z-index: 100 !important;
    transform: translateX(-35%) translateY(-10px) rotate(0deg) scale(1.15) !important;
    box-shadow: 0 30px 70px rgba(0, 0, 0, 0.35);
}

.slice-2:hover {
    z-index: 100 !important;
    transform: translateX(0%) translateY(-10px) rotate(0deg) scale(1.2) !important;
    box-shadow: 0 30px 70px rgba(0, 0, 0, 0.35);
}

.slice-3:hover {
    z-index: 100 !important;
    transform: translateX(35%) translateY(-10px) rotate(0deg) scale(1.15) !important;
    box-shadow: 0 30px 70px rgba(0, 0, 0, 0.35);
}

/* Feature Title Styling */
.feature-title {
    display: flex;
    flex-direction: column;
    /* Stack titles vertically */
    align-items: flex-start;
    line-height: 1.2;
}

.title-en {
    font-size: 3.5rem;
    font-weight: 800;
    color: #1a1a1a;
}

.title-jp {
    font-size: 1.5rem;
    font-weight: 500;
    color: #888;
    margin-top: 0.2rem;
    font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
}

/* Responsive */
@media (max-width: 768px) {
    .feature-visual {
        height: 300px;
    }

    .collage-slice {
        width: 80%;
        border-width: 2px;
    }

    .slice-1 {
        transform: translateX(-15%) translateY(5%) rotate(-5deg);
    }

    .slice-3 {
        transform: translateX(15%) translateY(5%) rotate(5deg);
    }

    .feature-title {
        align-items: center;
    }

    .title-en {
        font-size: 2.5rem;
    }

    .title-jp {
        font-size: 1.2rem;
    }
}

/* Responsive adjustments */
@media (max-width: 1024px) {
    .feature-section {
        flex-direction: column;
        text-align: center;
        gap: 2rem;
        padding: 2rem 1rem;
    }

    .feature-content {
        max-width: 100%;
        order: 2;
        padding: 0 1rem;
    }

    .feature-header {
        justify-content: center;
        /* Center header on mobile */
        flex-direction: column;
        /* Stack icon on top of title */
        gap: 1rem;
    }

    .feature-icon {
        width: 80px;
        height: 80px;
    }

    .feature-visual {
        order: 1;
        width: 100%;
        height: 340px;
        /* Increased height for landscape cards */
        margin-bottom: 3rem;
        /* prevent overlap */
    }

    .block-main {
        width: 85%;
        height: 85%;
    }

    .feature-list {
        text-align: left;
        display: inline-block;
    }

    .feature-list li {
        text-align: left;
        font-size: 1rem;
    }

    .feature-title {
        font-size: 2rem;
    }

    .feature-description {
        font-size: 1rem;
        line-height: 1.6;
    }
}

/* Desktop Full-Width Breakout */
@media (min-width: 1024px) {
    .feature-section {
        width: 100vw;
        position: relative;
        left: 50%;
        right: 50%;
        margin-left: -50vw;
        margin-right: -50vw;
        padding-left: 10%;
        padding-right: 10%;
    }
}

/* --- About Me Section --- */
#about-me {
    padding: 6rem 0;
    position: relative;
    overflow: hidden;
}

.about-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4rem;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
}

/* Visual Stack */
.about-visual {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 400px;
    position: relative;
}

.card-stack {
    position: relative;
    width: 280px;
    height: 340px;
    perspective: 1000px;
}

.stack-item {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 12px;
    border: 2px solid #1a1a1a;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background-color: #fff;
    box-shadow: 4px 4px 0px rgba(0, 0, 0, 0.15);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform-origin: center center;
    font-family: 'Patrick Hand', cursive;
}

.stack-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

.stack-label {
    font-size: 1.5rem;
    font-weight: bold;
    color: #1a1a1a;
}

/* Base Shadow Item */
.item-base {
    background-color: #e5e5e5;
    z-index: 1;
    transform: rotate(-5deg);
    border: none;
    box-shadow: none;
}

/* Sailor Card */
.item-sailor {
    background-color: #dbeafe;
    /* Light Blue */
    z-index: 2;
    transform: rotate(-3deg);
    animation: float 6s ease-in-out infinite;
}

/* Engineer Card */
.item-dev {
    background-color: #f3f4f6;
    /* Light Gray */
    z-index: 3;
    transform: rotate(2deg);
    animation: float 7s ease-in-out infinite reverse;
}

/* Maker Card (Top) */
.item-maker {
    background-color: #ffedd5;
    /* Light Orange */
    z-index: 4;
    transform: rotate(-1deg);
    animation: float 5s ease-in-out infinite;
}

/* --- 切牌动效 (Card Deal Animation) --- */
/* 堆栈内 avatar 卡片的微偏移，模拟堆叠感 */
.avatar-card[data-card-index="1"] {
    transform: rotate(0.5deg) translate(2px, 2px);
}

.avatar-card[data-card-index="2"] {
    transform: rotate(-0.5deg) translate(-1px, 3px);
}

.avatar-card[data-card-index="3"] {
    transform: rotate(0.8deg) translate(1px, 4px);
}

/* 切牌滑出动画 - 保持可见 */
@keyframes deal-card {
    0% {
        transform: rotate(-1deg);
        opacity: 1;
    }

    100% {
        transform: translateX(-140%) translateY(20px) rotate(-15deg);
        opacity: 1;
    }
}

/* 切牌切回底部动画 */
@keyframes return-card {
    0% {
        transform: translateX(-140%) translateY(20px) rotate(-15deg);
        /* 此时 z-index 已经在 JS 中被置为底层了，所以它会从下面穿过 */
    }

    100% {
        transform: rotate(0deg) translate(0, 0);
        /* 回到原位，之后 JS 会移除类，恢复默认微偏移 */
    }
}

.card-dealing {
    animation: deal-card 0.5s cubic-bezier(0.25, 1, 0.5, 1) forwards !important;
    pointer-events: none;
    z-index: 100 !important;
}

.card-returning {
    animation: return-card 0.5s cubic-bezier(0.25, 1, 0.5, 1) forwards !important;
    pointer-events: none;
}

/* Hover Effects on Stack */
.card-stack:hover .item-sailor {
    transform: translate(-40px, -20px) rotate(-10deg);
    animation-play-state: paused;
}

.card-stack:hover .item-dev {
    transform: translate(40px, -10px) rotate(5deg);
    animation-play-state: paused;
}

.card-stack:hover .item-maker:not(.card-dealing) {
    transform: translate(0, -40px) rotate(0deg) scale(1.05);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
    animation-play-state: paused;
}

@keyframes float {
    0% {
        transform: translateY(0px) rotate(var(--r, 0deg));
    }

    50% {
        transform: translateY(-10px) rotate(var(--r, 0deg));
    }

    100% {
        transform: translateY(0px) rotate(var(--r, 0deg));
    }
}

/* Keyframe adjustments for specific rotations */
.item-sailor {
    --r: -3deg;
}

.item-dev {
    --r: 2deg;
}

.item-maker {
    --r: -1deg;
}

/* Text Content */
.about-content {
    flex: 1.2;
}

.section-title {
    font-family: 'Patrick Hand', cursive;
    font-size: 3rem;
    margin-bottom: 2rem;
    color: #1a1a1a;
    position: relative;
    display: inline-block;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: 5px;
    left: 0;
    width: 100%;
    height: 8px;
    background-color: rgba(22, 163, 74, 0.2);
    /* Soft Green highlight */
    z-index: -1;
    transform: skewX(-10deg);
}

.about-text p {
    font-size: 1.2rem;
    line-height: 1.8;
    color: #333;
    margin-bottom: 1.5rem;
}

/* Responsive */
@media (max-width: 768px) {
    .about-container {
        flex-direction: column;
        gap: 2rem;
        padding: 0 1.5rem;
    }

    .about-visual {
        order: 1;
        /* Move visual to top on mobile */
        min-height: 300px;
    }

    .card-stack {
        width: 220px;
        height: 280px;
    }

    .about-content {
        order: 2;
        text-align: left;
    }

    .stack-icon {
        font-size: 2.5rem;
    }

    .stack-label {
        font-size: 1.2rem;
    }
}


/* --- 滚动加载动画 (Scroll Animations) --- */
.scroll-hidden {
    opacity: 0;
    transform: translateY(60px) scale(0.95);
    /* 初始下沉并稍微缩小 */
    transition: all 1.0s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    /* 弹性缓动 */
    filter: blur(10px);
    /* 增加一点模糊感 */
}

/* 激活状态 */
.scroll-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
}

/* 延迟控制 */
.delay-100 {
    transition-delay: 0.1s;
}

.delay-200 {
    transition-delay: 0.2s;
}

.delay-300 {
    transition-delay: 0.3s;
}
/* Reorder About Me section on mobile: Text first, then Image */
@media (max-width: 768px) {
    .about-visual {
        order: 2;
    }
    .about-content {
        order: 1;
    }
}

/* Reorder Projects section on mobile: Text first, then Image */
@media (max-width: 1024px) {
    .feature-content {
        order: 1;
    }
    .feature-visual {
        order: 2;
    }
}

/* Project Images Styling */
.project-img {
    display: block;
    width: 100%;
    max-width: 500px; /* Prevent them from being too large on wide screens */
    height: auto;
    margin-bottom: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    pointer-events: none; /* Disable interaction as requested */
}

/* Adjust feature-visual to accommodate stacked images */
.feature-visual {
    flex-direction: column !important; /* Force column layout */
    height: auto !important; /* Allow content to dictate height */
    padding: 2rem 0;
}
