/*
Theme Name: T-Change Design
Theme URI: https://www.t-changedesign.com
Author: T-Change Design
Author URI: https://www.t-changedesign.com
Description: A minimal portfolio theme for T-Change Design, inspired by lleditions.se
Version: 1.5.1
Requires at least: 6.4
Tested up to: 6.7
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: tchange-theme
Tags: portfolio, block-themes, full-site-editing, grid-layout
*/

/* 全局布局修正：强力去除所有默认间距 */
body,
.wp-site-blocks,
.wp-block-group.alignfull,
.wp-block-query.alignfull,
.is-layout-flow>.alignfull,
.is-layout-constrained>.alignfull,
.has-global-padding,
.has-global-padding>.alignfull {
    margin: 0 !important;
    padding: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
}

/* 特别针对 Gutenberg 的 root padding 变量 */
:root {
    --wp--style--global--content-size: 100%;
    --wp--style--global--wide-size: 100%;
}

/* 移除 Gutenberg 自动添加的 Gap */
.wp-site-blocks>*+* {
    margin-top: 0 !important;
}

/* Header 样式：增加高度到 50px */
header .wp-block-group {
    min-height: 50px !important;
    padding: 0.5rem 1rem !important;
    display: flex;
    align-items: center;
}

/* Sticky Header Implementation */
header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background-color: var(--wp--preset--color--background, #fff);
    width: 100%;
}

/* Ensure no gap above header */
body {
    margin-top: 0 !important;
}

header .wp-block-site-title {
    font-size: 1.25rem !important;
}

header .wp-block-site-title a {
    text-decoration: none !important;
}

/* 完美网格布局 (Perfect Grid) - Flexbox + Contain 策略 */
.perfect-grid {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 0 !important;
    width: 100%;
    /* 边框策略：只保留左边框，项目负责右和下边框 */
    border-left: 1px solid var(--wp--preset--color--primary);
    margin: 0 !important;
    padding: 0 !important;
    max-width: none !important;
    /* 确保无限制 */
}

/* 网格项样式 */
.perfect-grid>* {
    margin: 0 !important;
    padding: 0 !important;
    position: relative;
    box-sizing: border-box !important;
    /* 边框策略：每个元素负责右和下边框 */
    border: none !important;
    border-right: 1px solid var(--wp--preset--color--primary) !important;
    border-bottom: 1px solid var(--wp--preset--color--primary) !important;
    background-color: var(--wp--preset--color--secondary);
    display: flex;
    flex-direction: column;
    height: auto !important;
    /* 允许内容撑开 */
}

/* 2列布局 (桌面端) */
@media (min-width: 782px) {
    .perfect-grid>* {
        width: 50% !important;
        flex-basis: 50% !important;
        max-width: 50% !important;
    }
}

/* 2列布局 (平板端) */
@media (max-width: 781px) and (min-width: 600px) {
    .perfect-grid>* {
        width: 50% !important;
        flex-basis: 50% !important;
        max-width: 50% !important;
    }
}

/* 1列布局 (手机端) */
@media (max-width: 599px) {
    .perfect-grid>* {
        width: 100% !important;
        flex-basis: 100% !important;
        max-width: 100% !important;
    }
}

/* 图片容器：固定比例黑色背景 */
.perfect-grid-image-container,
.perfect-grid .wp-block-post-featured-image {
    margin: 0 !important;
    padding: 0 !important;
    background-color: #000;
    /* 黑色背景 */
    width: 100%;
    aspect-ratio: 16 / 10;
    /* 16:10 比例 */
    display: block !important;
    overflow: hidden;
    position: relative;
    flex-shrink: 0;
    /* 防止被压缩 */
    border-bottom: 1px solid var(--wp--preset--color--primary);
    /* 图片和文字之间的分隔线 */
}

/* 图片本身：Cover 模式铺满容器 */
.perfect-grid-image-container img,
.perfect-grid .wp-block-post-featured-image img,
.perfect-grid .wp-block-post-featured-image a img {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    object-fit: cover !important;
    object-position: center center !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    display: block !important;
}

/* 内容区域 padding */
.perfect-grid-details,
.perfect-grid .wp-block-group {
    padding: 12px !important;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    /* 内容上下对齐 */
    background: #fff;
    min-height: 80px;
    /* 确保文字区域有最小高度，保持统一感 */
}

/* 移除其他的干扰样式 */
.wp-block-post-template.perfect-grid {
    display: flex !important;
    border-top: 1px solid #000;
    /* 添加顶部边框线 */
}

.perfect-grid a {
    text-decoration: none !important;
}

/* ============================================
   Hero Carousel 轮播图样式
   ============================================ */

.hero-carousel {
    position: relative;
    width: 100%;
    overflow: hidden;
    background: #000;
}

/* 轮播容器 */
.hero-slides {
    display: block !important;
    width: 100%;
    position: relative;
    min-height: 400px;
}

/* 单个轮播项（WordPress 生成的任何子元素） */
.hero-slides>* {
    width: 100%;
    box-sizing: border-box;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}

/* 所有轮播项叠加，由 JS 控制 opacity 显示 */
.hero-slides>* {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
}

/* 第一个幻灯片默认显示并撑开容器高度 */
.hero-slides>*:first-child {
    position: relative;
    opacity: 1;
}

/* 轮播图片（适用于所有幻灯片） */
.hero-slides .wp-block-post-featured-image {
    width: 100%;
    /* 100vh - Header(50px) - TextBar(50px) = Full Screen Alignment */
    height: calc(100vh - 100px);
    min-height: 400px;
    max-height: none;
    /* remove max-height limit */
    margin: 0 !important;
    aspect-ratio: 16 / 9;
}

/* 确保 Hero Carousel 容器有高度 */
.hero-carousel,
.hero-carousel .wp-block-query {
    min-height: 400px;
}

.hero-slides .wp-block-post-featured-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 轮播详情（标题等） */
/* 轮播详情（标题等） */
.hero-details {
    position: relative;
    bottom: auto;
    left: 0;
    right: 0;
    background: #fff;
    color: #000;
    height: 50px;
    border: 1px solid #000;
    /* 白色黑线格子 */
    display: flex;
    align-items: center;
    padding: 0 1.5rem !important;
    box-sizing: border-box;
    margin-top: 0 !important;
    /* 移除可能的默认间距 */
}

.hero-details a {
    color: #000 !important;
    text-decoration: none !important;
}

.hero-details h3 {
    margin: 0;
    font-size: 0.875rem;
    /* 调整为 H3 样式的大小 (与 Recent Works 一致) */
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 轮播控制按钮 */
.hero-controls {
    position: absolute;
    bottom: 60px;
    /* Above the 50px text bar */
    top: auto;
    /* Remove top positioning */
    left: 0;
    right: 0;
    transform: none;
    /* Remove centering */
    display: flex;
    justify-content: space-between;
    padding: 0 1.5rem;
    /* Match details padding */
    pointer-events: none;
    z-index: 10;
}

/* Hide arrows on mobile */
@media (max-width: 768px) {
    .hero-controls {
        display: none !important;
    }
}

.hero-prev,
.hero-next {
    background: transparent;
    color: transparent;
    border: none;
    width: 40px;
    /* Consistently smaller size */
    height: 40px;
    padding: 0;
    font-size: 0;
    cursor: pointer;
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
    opacity: 1;
    /* Fully visible for blend mode */
    mix-blend-mode: difference;
    /* Adaptive color */
}

.hero-prev::before,
.hero-next::before {
    content: '';
    display: block;
    width: 16px;
    height: 16px;
    border-top: 2px solid #fff;
    /* White base for difference */
    border-right: 2px solid #fff;
}

/* 左箭头：旋转 -135度 */
.hero-prev::before {
    transform: rotate(-135deg);
    margin-left: 5px;
}

/* 右箭头：旋转 45度 */
.hero-next::before {
    transform: rotate(45deg);
    margin-right: 5px;
}

.hero-prev:hover,
.hero-next:hover {
    background: transparent;
    opacity: 0.8;
}

/* 响应式调整 */
@media (max-width: 768px) {
    .hero-slide .wp-block-post-featured-image {
        height: 50vh;
        min-height: 300px;
    }

    .hero-details h2 {
        font-size: 1.125rem;
    }

    .hero-prev,
    .hero-next {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
}

/* Works Page Spacing (Request: header/works 70px, works/footer 70px) */
/* Works Page ID 31 (from browser inspection) */
/* Specificity increased to override .wp-block-group.alignfull (0-2-0) */
.page-id-31 main.wp-block-group {
    margin-top: 70px !important;
    margin-bottom: 70px !important;
}

/* ============================================
   Project Detail Page Styles
   ============================================ */

/* Project Carousel */
/* Project Carousel */
/* Project Carousel */
.project-carousel {
    position: relative;
    width: 100%;
    background: #000;
    margin-bottom: 0 !important;
    /* Force Fix blank space */
    padding: 0 !important;
    line-height: 0;
    overflow: hidden;
    /* Clip the sliding track */
    display: flex;
    /* Remove inline-block spacing issues */
    flex-direction: column;
}

.project-carousel .project-slides {
    width: 100%;
    height: calc(100vh - 50px);
    /* overflow: hidden;  <-- REMOVED so slides can exist to the right */
    position: relative;
    display: flex;
    /* Enable Horizontal Layout */
    flex-wrap: nowrap;
    transition: transform 0.5s ease-in-out;
    /* Smooth slide */
}

/* Individual slide styling */
.project-carousel .project-slide {
    min-width: 100%;
    /* Occupy full width */
    width: 100%;
    height: 100%;
    position: relative;
    /* No longer absolute */
    opacity: 1 !important;
    /* Always visible */
    flex-shrink: 0;
    /* Prevent shrinking */
}

/* Fullscreen Images/Video */
.project-carousel .project-slides img,
.project-carousel .project-slide img,
.project-carousel .project-slide video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Carousel Controls */
.project-carousel-controls {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 1rem;
    z-index: 10;
}

.project-prev,
.project-next {
    background: transparent;
    border: 2px solid #fff;
    color: #fff;
    width: 40px;
    height: 40px;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
}

.project-prev:hover,
.project-next:hover {
    opacity: 0.7;
}

.project-counter {
    color: #fff;
    font-size: 0.875rem;
    font-family: var(--wp--preset--font-family--inter), sans-serif;
    letter-spacing: 0.05em;
}

/* ============================================
   Info Grid Layout (Reference: lleditions.se)
   Column widths: 1/4 + 1/2 + 1/4
   Enclosed borders (boxed grid style)
   Content-only mode: no labels displayed
   ============================================ */
.project-info-grid {
    width: 100%;
    border: 1px solid #000;
    box-sizing: border-box;
}

/* Remove ALL default WP block margins/paddings to fix row gaps */
.project-info-grid,
.project-info-grid * {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}

.project-info-grid>.wp-block-group__inner-container,
.info-row>.wp-block-group__inner-container {
    display: contents;
}

/* Hide all labels - content only mode */
.project-info-grid .cell-label {
    display: none !important;
}

/* Remove any nested borders inside cells (WP block groups) */
.info-cell .wp-block-group,
.info-cell .wp-block-group__inner-container,
.info-cell>div {
    border: none !important;
    border-left: none !important;
    border-right: none !important;
    padding: 0 !important;
    margin: 0 !important;
}

.info-row {
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: flex-start !important;
    /* 文字上对齐 */
    gap: 0 !important;
    /* 移除WP默认24px gap，防止溢出 */
    width: 100%;
    border-bottom: 1px solid #000;
    box-sizing: border-box;
}

.info-row:last-child {
    border-bottom: none;
}

/* Direct children of info-row that are cells */
.info-row>.info-cell,
.info-row>.wp-block-group.info-cell {
    padding: 2rem;
    border-left: none;
    border-right: none;
    box-sizing: border-box;
    min-height: 100px;
    vertical-align: top;
    /* 内容上对齐 */
    align-self: stretch;
    /* 确保单元格等高 */
}

/* Use border-left on non-first cells to create vertical dividers */
.info-row>.info-cell:not(:first-child),
.info-row>.wp-block-group.info-cell:not(:first-child) {
    border-left: 1px solid #000;
}

/* Column widths: 1/4 (25%) + 1/2 (50%) + 1/4 (25%) */
/* Left cells (25%): summary, category */
.info-row>.summary-cell,
.info-row>.category-cell,
.info-row>.wp-block-group.summary-cell,
.info-row>.wp-block-group.category-cell {
    flex: 0 0 25% !important;
    width: 25% !important;
    max-width: 25% !important;
}

/* Center cells (50%): intro, client */
.info-row>.intro-cell,
.info-row>.client-cell,
.info-row>.wp-block-group.intro-cell,
.info-row>.wp-block-group.client-cell {
    flex: 0 0 50% !important;
    width: 50% !important;
    max-width: 50% !important;
}

/* Right cells (25%): info-cell-right, time */
.info-row>.info-cell-right,
.info-row>.time-cell,
.info-row>.wp-block-group.info-cell-right,
.info-row>.wp-block-group.time-cell {
    flex: 0 0 25% !important;
    width: 25% !important;
    max-width: 25% !important;
}

/* ============================================
   统一网格单元格字体样式
   Unified Typography for all grid cells
   ============================================ */

/* 所有单元格基础字体 */
.project-info-grid .info-cell,
.project-info-grid .info-cell p,
.project-info-grid .info-cell span,
.project-info-grid .info-cell div {
    font-family: "Noto Sans SC", "PingFang SC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 0.875rem;
    line-height: 1.8;
    color: #000;
}

/* 第一行单元格 - 主要内容 */
.info-row-1 .info-cell {
    font-size: 0.9rem;
    line-height: 1.9;
}

/* 第二行单元格 - 次要信息 */
.info-row-2 .info-cell {
    font-size: 0.875rem;
    line-height: 1.7;
    padding: 1.5rem 2rem;
}

/* 项目信息单元格 - 支持换行，行间距紧凑 */
/* 项目信息单元格 - 支持换行，行间距紧凑 */
.info-cell.info-cell-right .project-field-value,
.params-cell .params-list {
    white-space: pre-wrap;
    line-height: 1.4;
    /* 保留换行符，紧凑行距 */
}

/* Cell Content Styling */
.cell-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #666;
    margin: 0 0 1rem 0;
    font-family: var(--wp--preset--font-family--inter), sans-serif;
}

.cell-content {
    font-size: 0.875rem;
    line-height: 1.8;
    margin: 0;
}

/* Introduction Cell - 介绍区域 */
.intro-cell {
    font-size: 0.9rem;
    line-height: 1.9;
    text-align: justify;
}

/* 介绍区域段落间距 - 增大段落间距 */
.intro-cell p {
    margin-bottom: 1.5em;
}

.intro-cell p:last-child {
    margin-bottom: 0;
}

/* ============================================
   Mobile Responsive - Stack grid into 1 column
   Reference: lleditions.se responsive behavior
   ============================================ */
@media (max-width: 768px) {

    /* Info Grid: Stack rows */
    .project-info-grid {
        border: 1px solid #000;
    }

    .info-row {
        flex-direction: column !important;
        flex-wrap: wrap !important;
    }

    /* All cells: full width, no vertical borders, add bottom border */
    .info-row>.info-cell,
    .info-row>.wp-block-group.info-cell {
        flex: 0 0 100% !important;
        width: 100% !important;
        max-width: 100% !important;
        border-left: none !important;
        border-right: none !important;
        border-bottom: 1px solid #000;
        padding: 1.5rem;
    }

    /* Last cell in each row: keep border (rows still separate) */
    .info-row>.info-cell:last-child,
    .info-row>.wp-block-group.info-cell:last-child {
        border-bottom: 1px solid #000;
    }

    /* Last row's last cell: no bottom border */
    .info-row:last-child>.info-cell:last-child,
    .info-row:last-child>.wp-block-group.info-cell:last-child {
        border-bottom: none;
    }

    /* Keep row border for visual separation between sections */
    .info-row {
        border-bottom: none;
    }

    /* Carousel height on mobile */
    .project-carousel .project-slides,
    .project-carousel .project-slide {
        height: 50vh;
        min-height: 300px;
    }

    /* Fullscreen Images/Video - Mobile */
    .project-slide img,
    .project-slide video {
        width: 100%;
        height: 100%;
        object-fit: cover;
        display: block;
    }

    /* Carousel controls smaller on mobile */
    .project-carousel-controls {
        padding: 0.75rem;
    }

    .project-prev,
    .project-next {
        font-size: 1.25rem;
        padding: 0.25rem 0.75rem;
    }

    .project-counter {
        font-size: 0.75rem;
    }
}

/* ============================================
   Interactive Carousel Styling
   ============================================ */

/* Make carousel relative for absolute positioning of zones */
.project-carousel {
    position: relative;
    /* Ensure it handles clicks */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Click Zones */
/* Click Zones */
.carousel-click-zone {
    position: absolute;
    top: 0;
    height: 100%;
    width: 50%;
    z-index: 20;
    background: transparent;
    margin: 0 !important;
    cursor: none;
    /* Hide default cursor */
}

.zone-left {
    left: 0;
}

.zone-right {
    right: 0;
}

/* Custom Cursor */
.project-cursor {
    position: fixed;
    top: 0;
    left: 0;
    width: 32px;
    height: 32px;
    pointer-events: none;
    z-index: 100;
    mix-blend-mode: difference;
    transform: translate(-50%, -50%);
    display: none;
    /* Hidden by default, shown by JS */
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
}

/* Hide custom cursor on touch devices or small screens */
@media (hover: none) and (pointer: coarse),
(max-width: 768px) {
    .project-cursor {
        display: none !important;
    }

    /* Restore standard tap behavior if needed, generally click zones handle it */
}

/* Cursor States managed by JS classes */
.project-cursor.arrow-left {
    /* White Arrow SVG for Difference Mode */
    background-image: url('data:image/svg+xml;utf8,<svg width="32" height="32" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg"><path d="M20 6 L10 16 L20 26" stroke="white" stroke-width="1.5" fill="none"/></svg>');
}

.project-cursor.arrow-right {
    /* White Arrow SVG for Difference Mode */
    background-image: url('data:image/svg+xml;utf8,<svg width="32" height="32" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg"><path d="M12 6 L22 16 L12 26" stroke="white" stroke-width="1.5" fill="none"/></svg>');
}

/* Edge Numbers Container */
.carousel-numbers {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    margin: 0 !important;
    z-index: 10;
}

/* Edge Numbers */
.edge-number {
    position: absolute;
    bottom: 1.5rem;
    /* Move to bottom */
    top: auto;
    transform: none;
    /* Remove centering transform */
    /* z-index: 10; handled by container */
    pointer-events: none;
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    font-weight: 400;
    color: #fff;
    /* White base for difference mode */
    mix-blend-mode: difference;
    /* Adaptive color (Inverts bg) */
    margin: 0 !important;
    padding: 0 !important;
    line-height: 1;
}

.number-current {
    left: 1.5rem;
    /* Explicit left positioning */
    right: auto;
}

.number-total {
    right: 1.5rem;
    /* Explicit right positioning */
    left: auto;
}

/* Hide old controls if they still exist in DOM */
.project-carousel-controls {
    display: none !important;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .edge-number {
        font-size: 0.875rem;
        bottom: 1rem;
        /* Closer to bottom on mobile */
    }

    .number-current {
        left: 1rem;
    }

    .number-total {
        right: 1rem;
    }

    /* On mobile, cursors don't matter, but tap zones still work */
}

/* ============================================
   Mobile Menu Styling (Existing) ...
   ============================================ */
@media (max-width: 600px) {

    /* Overlay Container */
    .wp-block-navigation__responsive-container.is-menu-open {
        background-color: var(--wp--preset--color--background, #fff) !important;
        padding-top: 2rem;
    }

    /* Content Wrapper */
    .wp-block-navigation__responsive-container .wp-block-navigation__responsive-container-content {
        width: 100% !important;
        align-items: center !important;
    }

    /* Menu Items Container (UL) */
    .wp-block-navigation__responsive-container .wp-block-navigation__container {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: flex-start !important;
        width: 100% !important;
        gap: 0 !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    /* Individual Menu Items */
    .wp-block-navigation__responsive-container .wp-block-navigation-item {
        width: 100% !important;
        display: flex !important;
        justify-content: center !important;
        text-align: center !important;
        border-bottom: 1px solid var(--wp--preset--color--primary);
        padding: 1.5rem 0;
        margin-bottom: 0 !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    /* Top border for the first item */
    .wp-block-navigation__responsive-container .wp-block-navigation-item:first-child {
        border-top: 1px solid var(--wp--preset--color--primary);
    }

    /* Link text styling */
    .wp-block-navigation__responsive-container .wp-block-navigation-item__content {
        font-size: 1.2rem;
        text-transform: uppercase;
        letter-spacing: 0.1em;
        width: 100%;
        display: block;
    }
}

/* ============================================
   Site Logo (SVG) Styling
   ============================================ */
.site-logo {
    display: flex;
    align-items: center;
    /* Ensure local alignment doesn't break flex parent */
}

.site-logo img {
    height: 38px;
    /* Increased from 24px */
    width: auto;
    display: block;
    transition: opacity 0.3s ease;
}

/* Default State (White Header Background) */
/* Show Black Logo, Hide White Logo */
.site-logo .logo-white {
    display: none;
}

.site-logo .logo-black {
    display: block;
}

/* Ensure Header Alignment (Logo Left, Menu Right) */
header .wp-block-group {
    justify-content: space-between !important;
}