body {
    margin: 0;
    font-family: 'Segoe UI', sans-serif;
    background-color: #1e1e1e;
    color: #f0f0f0;
}

section {
    padding: 2em;
    max-width: 1200px;
    margin: 0 auto;
}

.portfolio-page section {
    padding-top: 150px;
}

section#contact {
    padding: 2em;
    max-width: 800px;
    margin-left: 100px;
    margin-right: auto;
    text-align: left;
    padding-left: 0;
    box-sizing: border-box;
}

footer {
    text-align: center;
    padding: 2em;
    background-color: #1e1e1e;
    font-size: 0.9em;
    color: #aaa;
}

.contact-icons {
    display: flex;
    gap: 30px;
    margin: 15px 0;
}

.icon-link {
    color: #f0f0f0;
    text-decoration: none;
    font-size: 2em;
}

.icon-link:hover {
    color: #ff0080;
}

.grid {
    max-width: 100%;
    margin: 0 auto; /* 移除 flexbox 相關屬性，讓 Masonry 自己處理排版和置中 */
    padding: 0;
}

.grid-item {
    max-width: 240px;
    margin-bottom: 16px;
    break-inside: avoid;
    opacity: 0; /* 預設隱藏圖片 */
    transition: opacity 0.5s ease-in-out; /* 淡入效果 */
}

.grid-item.visible {
    opacity: 1; /* 載入後顯示圖片 */
}

.grid-item img {
    width: 100%;
    height: auto;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s ease;
}

.grid-item img:hover {
    transform: scale(1.03);
    cursor: pointer;
}

.lb-data .lb-caption {
    color: rgba(0, 0, 0, 0.073);
}

.hero-header {
    min-height: 350px;
    background-image: url('images/header-background.jpg');
    background-size: cover;
    background-position: 40% 52%;
    background-repeat: no-repeat;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    color: #fff;
    text-align: center;
}

.header-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    padding: 20px;
    box-sizing: border-box;
}

.hero-header h1 {
    margin: 0;
    font-size: clamp(1.8em, 4vw, 1.7em);
    position: relative;
    top: 20px;
    text-align: left;
    flex-shrink: 0;
    line-height: 1;
}

.hero-header nav {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    width: 100%;
    padding-right: 20px;
    box-sizing: border-box;
    padding-top: 10px;
    margin-top: 20px;
}

.hero-header nav a {
    color: white;
    text-decoration: none;
    font-weight: bold;
    padding: 10px;
    font-size: 1.2em;
    margin-left: clamp(10px, 2vw, 20px);
    margin-right: clamp(10px, 2vw, 20px);
    transition: color 0.3s ease;
    border-radius: 5px;
}

.hero-header nav a:hover {
    color: #00ffff;
}

.hero-text {
    margin-top: 125px;
    margin-bottom: 50px;
    font-size: clamp(1.2em, 2.5vw, 1.6em);
    line-height: 1.5;
    width: 80%;
    margin: 125px auto 50px;
    text-align: center;
    background: linear-gradient(to right, #00ffff, #ff0080);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}

header {
    background-color: transparent;
}

.header-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 20px;
    background: linear-gradient(to bottom, #ffffff9e, #928c8c3e);
    position: absolute;
    padding: 0 20px;
    box-sizing: border-box;
    top: 0;
    left: 0;
    flex-wrap: wrap;
    z-index: 99;
}

.hero-header-plain {
    background-image: none;
    background-color: transparent;
    height: auto;
    min-height: 0;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.lightbox .lb-close {
    position: absolute;
    top: 0;
    right: 200px;
    z-index: 9999;
    cursor: pointer;
    width: 36px;
    height: 36px;
    background: url('images/close.png') no-repeat;
    background-size: contain;
}

.lightbox .lb-dataContainer {
    padding-top: 20px;
}

.lightbox .lb-data {
    padding: 0 10px;
}

.lightbox .lb-dataContainer .lb-number {
    margin-right: 40px;
}

.dropdown {
    position: relative;
    display: inline-block;
}

.dropbtn {
    color: black;
    text-decoration: none;
    font-weight: bold;
    padding: 8px 12px;
    border-radius: 5px;
    transition: background-color 0.3s ease, color 0.3s ease;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
}

.dropbtn:hover {
    background-color: rgba(0, 0, 0, 0.1);
    color: #00ffff;
}

.dropdown-content {
    display: none;
    position: absolute;
    background-color: rgba(66, 65, 65, 0.8);
    min-width: 160px;
    box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.2);
    z-index: 100;
    border-radius: 5px;
    left: 0;
    top: 100%;
}

.dropdown-content a {
    color: black;
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    text-align: left;
    transition: background-color 0.2s ease;
    border-radius: 5px;
}

.dropdown-content a:hover {
    background-color: #ddd;
    color: #00ffff;
}

.dropdown:hover .dropdown-content {
    display: block;
}

.hero-header nav a,
.hero-header nav .dropbtn {
    margin-left: 20px;
}

.hero-header nav .dropbtn {
    margin-left: 20px;
}

.dropbtn i {
    vertical-align: middle;
}

.hamburger-menu {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px;
    z-index: 1000;
    position: relative;
    width: 40px;
    height: 30px;
    flex-shrink: 0;
}

.hamburger-menu .bar {
    display: block;
    width: 100%;
    height: 3px;
    top: 20px;
    background-color: white;
    border-radius: 2px;
    margin: 6px 0;
    transition: all 0.3s ease;
}

.hamburger-menu.active .bar:nth-child(1) {
    transform: translateY(9px) rotate(45deg);
}

.hamburger-menu.active .bar:nth-child(2) {
    opacity: 0;
}

.hamburger-menu.active .bar:nth-child(3) {
    transform: translateY(-9px) rotate(-45deg);
}

.main-nav {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    width: auto;
    padding-right: 20px;
    box-sizing: border-box;
}

body.no-scroll {
    overflow: hidden;
    height: 100vh;
}

@media screen and (max-width: 768px) {
    body {
        font-size: 15px;
    }

    body.no-scroll {
        overflow: hidden;
    }

    section {
        padding: 1.5em;
        margin: 0 15px;
    }

    section#contact {
        margin-left: 15px;
        padding-left: 15px;
    }

    .hero-header h1 {
        text-align: left;
        width: auto;
        font-size: clamp(1.8em, 5vw, 2.5em);
        margin: 0;
        flex-shrink: 0;
        line-height: 1;
        top: 0;
    }

    .hero-text {
        font-size: 1.5em;
        width: 90%;
        margin-top: 80px;
    }

    .hero-header {
        min-height: 250px;
    }

    .header-top-bar {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        position: fixed;
        background-color: rgba(0, 0, 0, 0.8);
        padding: 10px 15px;
        z-index: 1000;
        top: 0;
        left: 0;
        width: 100%;
        box-sizing: border-box;
    }

    .header-overlay {
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    .hamburger-menu {
        display: block;
        margin-left: auto;
        color: white;
        top: -2vh;
    }

    .hero-header-plain .hamburger-menu .bar {
        background-color: white;
    }

    .hero-header .main-nav {
        display: flex;
        flex-direction: column;
        position: fixed;
        top: 0;
        right: -100%;
        width: 70%;
        height: 100vh;
        background-color: rgba(30, 30, 30, 0.95);
        box-shadow: -5px 0 15px rgba(0, 0, 0, 0.5);
        transition: right 0.3s ease-out;
        z-index: 999;
        overflow-y: auto;
        justify-content: flex-start !important;
        align-items: center !important;
        padding-top: 0;
    }

    .hero-header .main-nav.active {
        right: 0;
    }

    .hero-header .main-nav a,
    .hero-header .main-nav .dropbtn {
        margin: 5px;
        padding: 15px;
        font-size: 1em;
        text-align: center;
        width: calc(100% - 40px);
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    .hero-header .main-nav a:last-child,
    .hero-header .main-nav .dropdown:last-child .dropbtn {
        border-bottom: none;
    }

    .dropdown-content {
        position: static;
        background-color: rgba(66, 65, 65, 0.8);
        box-shadow: none;
        min-width: unset;
        width: 100%;
        border-radius: 0;
    }

    .dropdown-content a {
        padding: 10px 30px;
        text-align: center;
        font-size: 0.9em;
        border-bottom: 1px dashed rgba(255, 255, 255, 0.05);
    }

    .dropdown-content a:last-child {
        border-bottom: none;
    }

    .lightbox {
        background-color: rgba(0, 0, 0, 0.9);
    }

    .lightbox .lb-outerContainer {
        position: fixed !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        width: auto !important;
        height: auto !important;
    }

    .lightbox .lb-image {
        max-width: 95vw !important;
        max-height: 80vh !important;
        object-fit: contain;
        width: auto !important;
        height: auto !important;
    }

    .lightbox .lb-dataContainer {
        display: none;
    }

    .lightbox .lb-close {
        position: fixed;
        top: 20px;
        right: 20px;
        z-index: 9999;
        width: 36px;
        height: 36px;
    }

    .grid {
        padding: 0 10px;
    }

    .grid-item {
        flex-basis: calc(100% - 20px);
        max-width: calc(100% - 20px);
        margin-right: 0;
    }

    .hero-header-plain {
        background-image: none;
        background-color: transparent;
        height: auto;
        min-height: 0;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        position: relative;
    }

    body.portfolio-page .hamburger-menu {
        display: none;
    }

    body.portfolio-page .hero-header .main-nav {
        display: flex;
        flex-direction: row;
        justify-content: flex-end;
        align-items: center;
        width: auto;
        position: static;
        top: unset;
        right: unset;
        height: auto;
        background-color: transparent;
        box-shadow: none;
        transition: none;
        z-index: auto;
        overflow-y: visible;
    }

    body.portfolio-page .hero-header .main-nav a,
    body.portfolio-page .hero-header .main-nav .dropbtn {
        margin: 0px 0px;
        padding: 10px;
        font-size: 1em;
        text-align: center;
        width: auto;
        border-bottom: none;
    }

    body.portfolio-page .dropdown-content {
        position: absolute;
        top: 100%;
        left: 0;
    }

    body.portfolio-page section {
        padding-top: 160px;
    }
}

@media screen and (max-width: 480px) {
    body {
        font-size: 14px;
    }

    .main-nav {
        width: 80%;
    }

    .hero-header h1 {
        font-size: clamp(1.5em, 6vw, 2.2em);
    }

    .hero-text {
        font-size: 1em;
        width: 95%;
    }

    .grid-item {
        flex-basis: 100%;
        max-width: 100%;
        margin-right: 0;
    }

    .contact-icons {
        gap: 20px;
        justify-content: center;
    }
}

@media screen and (max-width: 1024px) and (min-width: 769px) {
    section {
        padding: 2em;
        margin: 0 25px;
    }

    section#contact {
        margin-left: 50px;
        padding-left: 30px;
    }

    .grid-item {
        flex-basis: calc(33.333% - 20px);
        max-width: calc(33.333% - 20px);
    }
}