* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg-color: #ffffff;
    --text-main: #111827;
    --primary-color: #4f46e5;
    --ui-scale: 1.0;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', 'Noto Sans TC', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    font-size: calc(16px * var(--ui-scale));
}

/* Header & Footer Styles (V1.40) */
.site-header {
    width: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    display: flex;
    align-items: center;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    position: relative;
    z-index: 10;
}

.header-container {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-logo {
    height: 80%;
    max-height: 60px;
    width: auto;
    object-fit: contain;
}

.header-title {
    font-size: calc(1.75rem * var(--ui-scale));
    font-weight: 700;
    margin: 0;
    letter-spacing: 1px;
    color: inherit; /* 確保繼承自父層設定的顏色 */
}

.site-footer {
    width: 100%;
    padding: 40px 20px;
    text-align: center;
    font-size: calc(0.9rem * var(--ui-scale));
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin-top: 20px;
}

.footer-container {
    max-width: 1200px;
    margin: 0 auto;
    line-height: 1.6;
}

.footer-container p {
    margin-bottom: 8px;
}

.version-badge {
    text-align: center;
    padding: 30px 0;
    color: #999;
    font-size: 13px;
    width: 100%;
}

.site-section {
    width: 100%;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    border-bottom: 1px solid #eee;
    overflow: hidden;
    position: relative;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 10px 20px;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

/* If parent section has min-height and it's not auto, we might want less padding */
.site-section[style*="min-height:"] .container {
    padding-top: 5px;
    padding-bottom: 5px;
}

/* For Button Row, make it even more compact by default */
.site-section.section-type-button-row .container {
    padding-top: 5px;
    padding-bottom: 5px;
}

/* Fixed Height Enforcement for Browse Mode (V1.25: Robust Class-based) */
.site-section.has-fixed-height {
    height: var(--section-height);
}

@media (max-width: 770px) {
    .site-section.has-fixed-height {
        /* On mobile, if height is set, we scale it to roughly 70% to maintain better aspect ratio */
        height: calc(var(--section-height) * 0.7) !important;
        max-height: 75vh;
    }
}


.site-section.has-fixed-height {
    align-items: stretch;
}

.site-section.has-fixed-height .container,
.site-section.has-fixed-height .section-grid {
    height: 100%;
}

.site-section.has-fixed-height .item-card {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.site-section.has-fixed-height .item-image {
    flex: 1;
    overflow: hidden;
}

.site-section.has-fixed-height .item-image img {
    height: 100%;
    width: 100%;
    object-fit: cover; /* V1.23: NEVER distort images, always cover */
}


.section-type-button-row .container {
    padding: 5px 20px;
}

.section-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    flex-wrap: wrap; /* Prevent forcing desktop view on mobile Safari */
    gap: 10px;
}

.section-display-title {
    font-size: calc(1.5rem * var(--ui-scale));
    font-weight: 700;
    margin-bottom: 0;
    position: relative;
    padding-left: 15px;
}

.scroll-nav {
    display: flex;
    gap: 10px;
}

.nav-btn {
    width: calc(36px * var(--ui-scale));
    height: calc(36px * var(--ui-scale));
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: calc(14px * var(--ui-scale));
}

.nav-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.section-grid {
    display: grid;
    gap: 24px;
    transition: all 0.3s;
}

.display-scroll .section-grid {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none; /* Hide scrollbar Firefox */
    -ms-overflow-style: none;  /* Hide scrollbar IE/Edge */
    padding-bottom: 10px;
    gap: 24px;
}

.display-scroll .section-grid::-webkit-scrollbar {
    display: none; /* Hide scrollbar Chrome/Safari */
}

/* Horizontal Scroll Item Widths based on Type */
.display-scroll.section-type-full-img .item-card { flex: 0 0 100%; scroll-snap-align: center; }
.display-scroll.section-type-split-50 .item-card { flex: 0 0 calc(50% - 12px); scroll-snap-align: start; }
.display-scroll.section-type-grid-1x2 .item-card { flex: 0 0 calc(50% - 12px); scroll-snap-align: start; }
.display-scroll.section-type-grid-1x3 .item-card { flex: 0 0 calc(33.33% - 16px); scroll-snap-align: start; }
.display-scroll.section-type-button-row .item-card { flex: 0 0 calc(25% - 18px); scroll-snap-align: start; }
.display-scroll.section-type-grid-2x2 .item-card { flex: 0 0 calc(50% - 12px); scroll-snap-align: start; }

/* Layouts */
.layout-full-img { grid-template-columns: 1fr; }
.layout-split-50 { grid-template-columns: 1fr 1fr; }
.layout-grid-1x2 { grid-template-columns: 1fr 1fr; }
.layout-grid-1x3 { grid-template-columns: 1fr 1fr 1fr; }
.layout-button-row { 
    grid-template-columns: repeat(4, 1fr); 
}

.layout-grid-2x2 { grid-template-columns: 1fr 1fr; }

/* Item Card */
.item-card {
    background: white;
    border-radius: 16px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.3s ease;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
}

.item-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
}

.item-image {
    width: 100%;
    background: #f1f5f9;
    display: block;
    overflow: hidden;
}

/* Full Image Mode (Default) - Fits into a standard box without cropping */
.item-image.mode-full {
    display: block;
}

.item-image.mode-full img {
    width: 100%;
    height: auto;
    max-height: 100%;
    display: block;
    object-fit: contain;
    object-position: top;
}

.item-image.mode-width img {
    object-fit: cover;
    object-position: top;
}

.item-image.mode-circle {
    aspect-ratio: 1/1;
    border-radius: 50% !important;
    overflow: hidden;
    width: 80%;
    margin: 10px auto 0;
    background: transparent; /* Remove potential white/black background */
    -webkit-mask-image: -webkit-radial-gradient(white, black); /* Fix for Safari/Chrome clipping */
}

.item-image.mode-circle img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: transparent;
}

/* Fit Width Mode - Scales to full width, height is auto */
.item-image.mode-width img {
    width: 100%;
    height: auto;
    display: block;
}

.item-card:hover .item-image img {
    transform: scale(1.05);
}

.item-content {
    padding: 10px 1px;
}

.item-content h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1f2937;
}

/* Button Item (1*4 row) */
.button-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    gap: 12px;
}

.btn-circle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--primary-color);
}

.btn-image {
    width: 60px;
    height: 60px;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 8px;
    -webkit-mask-image: -webkit-radial-gradient(white, black);
}

.btn-image.mode-circle {
    border-radius: 50%;
}

.btn-image img {
    width: 100%;
    height: 100%;
}

.btn-image.mode-full img {
    object-fit: contain;
}

.btn-image.mode-width img,
.btn-image.mode-circle img {
    object-fit: cover;
}

/* Mobile Responsive */
@media (max-width: 770px) {
    .container {
        padding: 24px 15px;
    }
    
    .section-display-title {
        font-size: 1.25rem;
    }
    
    .scroll-nav {
        display: flex; /* Always show nav buttons */
    }
    
    .section-grid {
        gap: 16px;
    }
    
    .display-scroll .section-grid {
        display: flex !important;
        flex-direction: row !important;
        overflow-x: auto !important;
    }
    
    .display-scroll .item-card {
        flex: 0 0 260px;
    }
}

.empty-site {
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.empty-site a {
    margin-top: 20px;
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
}

/* --- V1.00 UI Zoom Support --- */
:root {
    --ui-scale: 1.0;
    --border-color: #e2e8f0;
}

body {
    font-size: calc(16px * var(--ui-scale));
}

.section-title {
    font-size: calc(1.5rem * var(--ui-scale));
}

.nav-btn {
    width: calc(36px * var(--ui-scale));
    height: calc(36px * var(--ui-scale));
    font-size: calc(14px * var(--ui-scale));
}

/* Floating Zoom Controls */
.floating-zoom-controls {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    background: white;
    border-radius: 50px;
    padding: 5px 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    z-index: 9999;
    border: 1px solid #e2e8f0;
}

.floating-zoom-controls .zoom-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: #f1f5f9;
    color: #64748b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.floating-zoom-controls .zoom-btn:hover {
    background: var(--primary-color);
    color: white;
}

.floating-zoom-controls #zoom-level {
    font-size: 14px;
    font-weight: 700;
    margin: 0 10px;
    min-width: 45px;
    text-align: center;
    color: #475569;
}
