/*
Theme Name: HKWL Theme
Theme URI: https://hkwl.org
Author: HKWL Team
Author URI: https://hkwl.org
Description: Custom theme for HKWL website.
Version: 1.2.1
License: GNU General Public License v2 or later
License URI: LICENSE
Text Domain: hkwl-theme
Tags: custom-background, custom-logo, custom-menu, featured-images, threaded-comments, translation-ready
*/

/* ============ TAILWIND CSS CUSTOM COLORS FALLBACK ============ */
/* HKWL Brand Colors - Semantic Names */
.bg-wk-blue { background-color: #4E77A7 !important; }
.bg-wk-orange { background-color: #4E77A7 !important; }
.bg-wk-red { background-color: #4E77A7 !important; }
.bg-wk-black { background-color: #4E77A7 !important; }

.text-wk-blue { color: #4E77A7 !important; }
.text-wk-orange { color: #4E77A7 !important; }
.text-wk-red { color: #4E77A7 !important; }

.border-wk-blue { border-color: #4E77A7 !important; }
.border-wk-orange { border-color: #4E77A7 !important; }
.border-wk-red { border-color: #4E77A7 !important; }

/* Hover States */
.hover\:bg-wk-blue:hover { background-color: #3a5f85 !important; }
.hover\:bg-wk-orange:hover { background-color: #3a5f85 !important; }
.hover\:bg-wk-red:hover { background-color: #3a5f85 !important; }
.hover\:text-wk-blue:hover { color: #3a5f85 !important; }
.hover\:text-wk-orange:hover { color: #3a5f85 !important; }
.hover\:text-wk-red:hover { color: #3a5f85 !important; }
.hover\:border-wk-blue:hover { border-color: #3a5f85 !important; }

/* Focus Ring */
.focus\:ring-wk-blue:focus { --tw-ring-color: rgba(78, 119, 167, 0.3) !important; }
.focus\:border-wk-blue:focus { border-color: #4E77A7 !important; }

/* ============ AOS FAIL-OPEN ============ */
/* AOS CSS hides [data-aos] elements by default. If the AOS JS fails to load
 * or initialize (e.g. blocked network), content must remain visible.
 * The .aos-ready class is added by theme.js only after AOS.init() succeeds. */
html:not(.aos-ready) [data-aos] {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
}

/* Legacy color names mapped to HKWL brand */
.bg-wk-dark { background-color: #3a5f85 !important; }
.bg-wk-gray { background-color: #3a5f85 !important; }
.bg-wk-bg { background-color: #f8fafc !important; }
.text-wk-text { color: #1a1a1a !important; }
.text-wk-text-secondary { color: #6b7280 !important; }

/* ============ CARDS ============ */
.card-lift {
    transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94), box-shadow 0.3s ease;
    will-change: transform;
}
.card-lift:hover {
    transform: translateY(-6px);
    box-shadow: 0 16px 40px rgba(0,0,0,0.1);
}

.card-img-zoom {
    overflow: hidden;
}
.card-img-zoom img {
    transition: transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.card-lift:hover .card-img-zoom img,
.group:hover .card-img-zoom img {
    transform: scale(1.05);
}

/* ============ HERO BANNER TITLES ============ */
.hero-banner-title {
    white-space: normal;
    word-break: keep-all;
    overflow-wrap: break-word;
}

/* ============ CHINESE PUNCTUATION KERNING ============ */
/* We intentionally do NOT use the experimental text-spacing-trim property,
 * which causes inconsistent rendering across browsers and operating systems.
 * JS-driven trimming for leading opening quotation marks in card titles.
 * Use inline-block with a negative margin so the mark is visually pulled
 * left without relying on the experimental text-spacing-trim property. */
.punctuation-trim {
    display: inline-block;
    margin-left: -0.35em;
    padding-right: 0.05em;
    transform: translateX(-0.02em);
}

/* Visual compensation for the absence of font-feature-settings: "palt".
 * A slightly lighter default weight and small negative letter-spacing make
 * CJK text feel lighter and more compact, closer to the reference rendering. */
body {
    font-weight: 350;
    letter-spacing: -0.01em;
}

/* Tighten the first line of clamped card titles to reduce the leading
 * quotation-mark gap, matching the reference site's kerning. */
.line-clamp-2::first-line,
.line-clamp-3::first-line {
    letter-spacing: -0.02em;
}

/* ============ HERO BANNER SLIDER ============ */
.hero-overlay {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 75%;
    background: linear-gradient(to top, rgba(0,0,0,0.75) 0%, rgba(0,0,0,0.4) 40%, rgba(0,0,0,0.05) 100%);
    z-index: 10;
}

#hero-slider {
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    touch-action: pan-y;
}
#hero-slider.is-dragging {
    cursor: grabbing;
}
#hero-slider .hero-slide a {
    -webkit-user-drag: none;
    user-drag: none;
}

.slider-track {
    display: flex;
    height: 100%;
    will-change: transform;
}
.hero-slide {
    flex-shrink: 0;
    width: 100%;
    height: 100%;
    position: relative;
}
.hero-slide img {
    transition: transform 8s cubic-bezier(0.25, 0.1, 0.25, 1.0);
    transform: scale(1.0);
}
.hero-slide img.ken-burns-active {
    transform: scale(1.08);
}

/* All sizes: full image without crop, auto height */
#hero-slider {
    height: auto !important;
    min-height: auto;
    background: transparent;
}
.hero-slide {
    height: auto;
}
.hero-slide a {
    height: auto;
}
.hero-slide img {
    object-fit: contain !important;
    height: auto;
}

/* Mobile & Tablet: no Ken Burns zoom, banner below header */
@media (max-width: 1365px) {
    #hero-slider {
        margin-top: 0;
    }
    .hero-slide img.ken-burns-active {
        transform: scale(1.0);
    }
}

/* Slider Controls */
.slider-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 30;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: white;
    border: 1px solid rgba(255,255,255,0.2);
}
.slider-btn:hover {
    background: rgba(255,255,255,0.3);
}
.slider-btn-prev { left: 24px; }
.slider-btn-next { right: 24px; }

/* Slider Dots */
.slider-dots {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 30;
    display: flex;
    gap: 8px;
}
.slider-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(255,255,255,0.4);
    cursor: pointer;
    transition: all 0.3s ease;
}
.slider-dot.active {
    background: white;
    width: 28px;
    border-radius: 5px;
}

/* ============ HORIZONTAL SCROLL GALLERY ============ */
.scrollbar-hide {
    -ms-overflow-style: none;
    scrollbar-width: none;
}
.scrollbar-hide::-webkit-scrollbar {
    display: none;
}

.gallery-card {
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
    border-radius: 0.75rem;
}
.gallery-card .card-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.7) 0%, rgba(0,0,0,0.2) 40%, transparent 100%);
    opacity: 0;
    transition: opacity 0.4s ease;
}
.gallery-card:hover .card-overlay {
    opacity: 1;
}
.gallery-card .card-title {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1rem;
    transform: translateY(20px);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.gallery-card:hover .card-title {
    transform: translateY(0);
    opacity: 1;
}
.gallery-card img {
    transition: transform 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* === All card text strictly left-aligned === */

/* Front-page 中華文化節 grid + single.php 相關活動 */
.card-lift .p-5,
.card-lift .p-5 > p,
.card-lift .p-5 > h3,
.card-lift .p-5 > h2 {
    text-align: left !important;
}

/* Archive / Category / Taxonomy grid */
article .p-5,
article .p-5 > span,
article .p-5 > h3,
article .p-5 > h2,
article .p-5 > p,
article .p-5 > div {
    text-align: left !important;
}

/* Slider overlay cards */
.gallery-card .card-title,
.gallery-card .card-title > span,
.gallery-card .card-title > h3,
.gallery-card .card-info-overlay > div,
.gallery-card .card-info-overlay > div > span,
.gallery-card .card-info-overlay > div > h3 {
    text-align: left !important;
}

/* Search results */
.search-result-item > a > p,
.search-result-item > a > h3,
.search-result-item > a > h2 {
    text-align: left !important;
}

/* Slider snap responsive: desktop snap-start, mobile snap-center */
.gallery-card {
    scroll-snap-align: start;
}
@media (max-width: 1024px) {
    .gallery-card {
        scroll-snap-align: center;
    }
}
.gallery-card:hover img {
    transform: scale(1.1);
}

/* Venue gallery overlay (Tailwind) */
.gallery-card .card-info-overlay {
    opacity: 0;
    transition: opacity 0.3s ease;
}
.gallery-card .card-info-overlay > div {
    transform: translateY(1rem);
    transition: transform 0.3s ease;
}
.gallery-card:hover .card-info-overlay {
    opacity: 1;
}
.gallery-card:hover .card-info-overlay > div {
    transform: translateY(0);
}

/* Mobile (touch devices): show overlay via Intersection Observer */
@media (hover: none) {
    .gallery-card.is-visible .card-overlay {
        opacity: 1;
    }
    .gallery-card.is-visible .card-title {
        transform: translateY(0);
        opacity: 1;
    }
    .gallery-card.is-visible img {
        transform: scale(1.1);
    }
    .gallery-card.is-visible .card-info-overlay {
        opacity: 1;
    }
    .gallery-card.is-visible .card-info-overlay > div {
        transform: translateY(0);
    }
}

/* ============ SEARCH OVERLAY ============ */
.search-overlay {
    animation: fadeIn 0.2s ease;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ============ UTILITY ============ */
.link-animated {
    position: relative;
    display: inline-block;
}
.link-animated::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background-color: currentColor;
    transition: width 0.3s ease;
}
.link-animated:hover::after {
    width: 100%;
}

.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ============ BUTTONS ============ */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: #4E77A7;
    color: white;
    font-weight: 600;
    padding: 0.75rem 2rem;
    border-radius: 9999px;
    transition: all 0.3s ease;
}
.btn-primary:hover {
    background-color: #3a5f85;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(78, 119, 167, 0.3);
}

.btn-outline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid white;
    color: white;
    font-weight: 600;
    padding: 0.75rem 2rem;
    border-radius: 9999px;
    transition: all 0.3s ease;
}
.btn-outline:hover {
    background: white;
    color: #1a1a1a;
}

/* ============ HEADER - SCROLL COLOR CHANGE EFFECT ============ */
/* Default: white background for non-home pages */
#masthead {
    background: #ffffff;
    transition: background 0.35s ease, box-shadow 0.35s ease;
}
#masthead .header-nav-link,
#masthead .mobile-nav-link,
#masthead .header-search-btn,
#masthead .header-lang-toggle {
    color: #1a1a1a;
    transition: color 0.35s ease, background-color 0.35s ease;
}
#masthead .header-logo {
    filter: none;
    transition: filter 0.35s ease, transform 0.35s ease;
}

/* Home page: gradient transparent overlay */
.home #masthead {
    background: linear-gradient(to bottom, rgba(0,0,0,0.6) 0%, rgba(0,0,0,0.3) 50%, rgba(0,0,0,0) 80%, rgba(0,0,0,0) 100%);
}
.home #masthead .header-nav-link,
.home #masthead .mobile-nav-link,
.home #masthead .header-search-btn,
.home #masthead .header-menu-btn,
.home #masthead .header-lang-toggle {
    color: #ffffff;
}
/* Logo: single img, src switched by JS on homepage */
#masthead .header-logo {
    filter: none;
    transition: filter 0.35s ease, transform 0.35s ease;
}
.home #masthead .mobile-menu-container {
    background-color: rgba(20, 20, 20, 0.98);
    border-color: rgba(255, 255, 255, 0.1);
}
.home #masthead .mobile-menu-container .mobile-nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Home page mobile & tablet: white header background with black text */
@media (max-width: 1365px) {
    .home #masthead {
        background: #ffffff;
    }
    .home #masthead .header-nav-link,
    .home #masthead .mobile-nav-link,
    .home #masthead .header-search-btn,
    .home #masthead .header-menu-btn,
    .home #masthead .header-lang-toggle {
        color: #1a1a1a;
    }
    .home #masthead .header-menu-btn:hover {
        background-color: rgba(0, 0, 0, 0.05);
    }
    .home #masthead .mobile-menu-container {
        background-color: rgba(255, 255, 255, 0.98);
        border-color: rgba(0, 0, 0, 0.1);
    }
    .home #masthead .mobile-menu-container .mobile-nav-link:hover {
        background-color: rgba(0, 0, 0, 0.05);
    }
}

/* Scrolled state: white background */
#masthead.header-scrolled {
    background: #ffffff !important;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
}
#masthead.header-scrolled .header-nav-link,
#masthead.header-scrolled .mobile-nav-link,
#masthead.header-scrolled .header-search-btn,
#masthead.header-scrolled .header-lang-toggle {
    color: #1a1a1a;
}
.home #masthead.header-scrolled .header-nav-link,
.home #masthead.header-scrolled .mobile-nav-link,
.home #masthead.header-scrolled .header-search-btn,
.home #masthead.header-scrolled .header-menu-btn,
.home #masthead.header-scrolled .header-lang-toggle {
    color: #1a1a1a;
}
#masthead.header-scrolled .header-logo {
    filter: none;
    transform: scale(0.95);
}
.home #masthead.header-scrolled .header-logo {
    filter: none;
}
#masthead.header-scrolled .header-menu-btn {
    color: #1a1a1a;
}
#masthead.header-scrolled .header-menu-btn:hover {
    background-color: rgba(0, 0, 0, 0.05);
}
.home #masthead.header-scrolled .mobile-menu-container {
    background-color: rgba(255, 255, 255, 0.98);
    border-color: rgba(0, 0, 0, 0.1);
}
.home #masthead.header-scrolled .mobile-menu-container .mobile-nav-link:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

/* Mobile menu button - default (white header) */
#masthead .header-menu-btn {
    color: #1a1a1a;
    transition: color 0.35s ease, background-color 0.35s ease;
}
#masthead .header-menu-btn:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

/* Mobile menu container - default light (matches white header) */
#masthead .mobile-menu-container {
    background-color: rgba(255, 255, 255, 0.98);
    border-color: rgba(0, 0, 0, 0.1);
    transition: background-color 0.35s ease, border-color 0.35s ease;
}
#masthead .mobile-menu-container .mobile-nav-link:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

/* Mobile menu container - scrolled white */
#masthead.header-scrolled .mobile-menu-container {
    background-color: rgba(255, 255, 255, 0.98);
    border-color: rgba(0, 0, 0, 0.1);
}
#masthead.header-scrolled .mobile-menu-container .mobile-nav-link:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

/* ============ MOBILE MENU SMOOTH ANIMATION ============ */
#mobile-menu {
    opacity: 0;
    transform: translateY(-8px);
    max-height: 0;
    overflow: hidden;
    pointer-events: none;
    transition: opacity 0.35s ease, transform 0.35s ease, max-height 0.35s ease;
}
#mobile-menu.menu-open {
    opacity: 1;
    transform: translateY(0);
    max-height: 600px;
    pointer-events: auto;
}

/* Hamburger icon animation */
.menu-line-top,
.menu-line-mid,
.menu-line-bot {
    transition: transform 0.3s ease, opacity 0.3s ease;
    transform-origin: center;
}
.menu-btn-active .menu-line-top {
    transform: translateY(6px) rotate(45deg);
}
.menu-btn-active .menu-line-mid {
    opacity: 0;
}
.menu-btn-active .menu-line-bot {
    transform: translateY(-6px) rotate(-45deg);
}

/* ============ NAV DROPDOWN ============ */
/* Desktop dropdown */
#site-navigation .group:hover .group-hover\:visible,
#site-navigation .group\/core:hover .group-hover\/core\:visible,
#site-navigation .group\/item:hover .group-hover\/item\:visible {
    visibility: visible;
}
#site-navigation .group:hover .group-hover\:opacity-100,
#site-navigation .group\/core:hover .group-hover\/core\:opacity-100,
#site-navigation .group\/item:hover .group-hover\/item\:opacity-100 {
    opacity: 1;
}

/* Mobile dropdown accordion */
.mobile-dropdown button[data-mobile-toggle] {
    -webkit-appearance: none;
    appearance: none;
}
.mobile-dropdown button[data-mobile-toggle] svg {
    transition: transform 0.2s ease;
}
.mobile-dropdown button[data-mobile-toggle][aria-expanded="true"] svg {
    transform: rotate(180deg);
}

/* Mobile dropdown children */
.mobile-dropdown-children {
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
}

/* Mobile slider cards always show info overlay */
@media (max-width: 1023px) {
    .gallery-card .card-info-overlay,
    .gallery-card .card-info-overlay > div,
    .gallery-card .card-overlay,
    .gallery-card .card-title {
        opacity: 1 !important;
        transform: translateY(0) !important;
    }
}

/* Xiaohongshu icon (SVG already white) */
.xiaohongshu-icon {
    filter: none;
}

/* ============ NEWS LIST ITEMS ============ */
.news-list-item {
    transition: all 0.2s ease;
}
.news-list-item:hover {
    background-color: #f8fafc;
}
.news-list-item:hover .news-title {
    color: #4E77A7;
}

/* ============ WeChat QR Tooltip ============ */
.wechat-tooltip {
    position: absolute;
    bottom: calc(100% + 16px);
    right: 0;
    transform: translateY(8px);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.25, 0.1, 0.25, 1.0);
    background: white;
    padding: 14px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    pointer-events: none;
    z-index: 50;
    width: fit-content;
    min-width: 248px;
}
.wechat-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    right: 12px;
    border: 10px solid transparent;
    border-top-color: white;
}
.wechat-tooltip img {
    width: 220px;
    height: 220px;
    object-fit: contain;
    border-radius: 8px;
    display: block;
}
.group:hover .wechat-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Text justify for all prose and content paragraphs */
.prose p,
.entry-content p,
.page-content p {
    text-align: justify;
}

/* Tighten vertical spacing inside prose to match editor view.
   Tailwind Typography defaults are too loose for this theme.
   Use .prose.prose-lg to ensure higher specificity than the CDN defaults. */
.prose.prose-lg p {
    margin-top: 0.75em;
    margin-bottom: 0.75em;
}
.prose.prose-lg figure {
    margin-top: 1em;
    margin-bottom: 1em;
}
.prose.prose-lg figure img {
    display: block;
    margin: 0;
}

/* Remove baseline gap inside figure by collapsing line-height.
   Restore line-height for figcaption if present. */
.prose.prose-lg figure {
    line-height: 0;
}
.prose.prose-lg figure figcaption {
    line-height: 1.5;
}

/* Empty paragraphs are intentionally preserved by the editor to create blank
   lines. Give them a minimum height so they render as visible line breaks
   instead of collapsing. */
.prose p:empty,
.entry-content p:empty,
.page-content p:empty {
    min-height: 0.75em;
}

/* Blue hyperlinks inside prose and event content */
.prose a,
.event-content a {
    color: #2563EB;
    text-decoration: underline;
}
.prose a:hover,
.event-content a:hover {
    color: #1D4ED8;
}

/* About us structure image language switching */
.structure-img-hk {
    display: block;
}
.structure-img-cn {
    display: none;
}
body.lang-simplified .structure-img-hk {
    display: none;
}
body.lang-simplified .structure-img-cn {
    display: block;
}

/* Ensure article images and captions fill the content column width.
   Use !important to override legacy inline styles from imported content. */
.prose figure,
.prose .wp-caption,
.prose .aligncenter,
.prose .alignnone,
.prose .alignleft,
.prose .alignright {
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    height: auto;
}
.prose figure img,
.prose .wp-caption img,
.prose .aligncenter img,
.prose .alignnone img,
.prose .alignleft img,
.prose .alignright img {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    display: block;
}
.prose img {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    display: block;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
    .slider-btn {
        width: 36px;
        height: 36px;
    }
    .slider-btn-prev { left: 12px; }
    .slider-btn-next { right: 12px; }
}
