/* ==========================================
   1. ORIGINAL STYLES PRESERVATION
   ========================================== */
table {
    width: 990px; 
    margin: auto;
}

div.imageright { float:right; margin: 0em 30; }
div.imageleft { float:left; margin: 0em 30; }
div.imagecentre { width: 100%; margin: auto; }

a.homepage:link, a.homepage:visited { 
    text-decoration: none; 
    color: #000000; 
    font-family: Verdana, Arial, sans-serif; 
    font-size: 28px; 
    font-weight: bold; 
}
a.homepage:hover { 
    text-decoration: underline; 
    color: #000000; 
    font-family: Verdana, Arial, sans-serif; 
    font-size: 28px; 
    font-weight: bold; 
}

a.navblack:link, a.navblack:visited { text-decoration: none; color: #000000; font-family: Verdana, Arial, sans-serif; font-size: 14px; font-weight: bold; }
a.navblack:hover { text-decoration: underline; color: #000000; font-family: Verdana, Arial, sans-serif; font-size: 14px; font-weight: bold; }
a.navblackchn:link, a.navblackchn:visited { text-decoration: none; color: #000000; font-family: 新細明體, Verdana, Arial, sans-serif; font-size: 16px; font-weight: bold; }
a.navblackchn:hover { text-decoration: underline; color: #000000; font-family: 新細明體, Verdana, Arial, sans-serif; font-size: 16px; font-weight: bold; }

h1 { font-family: Arial, sans-serif; font-size: 32px; text-align: center; font-weight: bold; }
h2 { font-family: Verdana, Arial, sans-serif; font-size: 28px; }
h3 { font-family: Verdana, Arial, sans-serif; font-size: 22px; }

h2.homepage { 
    font-family: Verdana, Arial, sans-serif; 
    font-size: 32px;
    text-align: center;
    font-weight: bold; 
    margin: 0 0 10px 0;
}

body.homepage, body.subpage, body.nobackground { 
    background-color: #FFFFE0;
    text-align: center;
    margin: 0;
    padding: 0;
}

p,b,i,em,dt,dd,dl,sl,caption,th,td,tr,u,blink,select,option,form,div,li { 
    font-family: Verdana, Arial, sans-serif; 
    font-size: 16px;
    vertical-align: top;
}
p.small { font-family: Verdana, Arial, sans-serif; font-size: 14px; text-align: justify; }

/* ==========================================
   2. RE-ENGINEERED CONTAINER FRAMEWORKS
   ========================================== */
.site-container {
    width: 100%;
    max-width: 990px;
    margin: 0 auto;
    box-sizing: border-box;
}

.header-outer-table {
    width: 100%;
    max-width: 990px;
    margin: 0 auto;
    border-collapse: collapse;
}

/* Vertically centers titles relative to the wheel emblem cell */
.header-inner-table {
    width: 100%;
    text-align: left;
}
.header-inner-table td {
    vertical-align: middle !important;
}

/* Holds logo dimensions cleanly on desktop viewports */
.logo-crop-box {
    width: 190px;
    height: 160px;
    overflow: hidden;
    display: block;
}
.site-logo-img {
    width: auto;
    height: auto;
    display: block;
}

.language-bar-strip {
    text-align: right !important;
}

/* Temple Banner Image Frame */
.temple-banner-frame {
    width: 928px;
    max-width: 100%;
    height: 336px;
    overflow: hidden;
    margin: 20px auto 0 auto;
    box-sizing: border-box;
}
.temple-photo-asset {
    width: 100%;
    height: auto;
    margin-top: -195px;
    display: block;
}

/* Content block locks exactly to 928px width layout tracks */
.menu-content-block {
    background-color: #EDE9BA !important;
    width: 928px;
    margin: 0 auto;
    position: relative; 
    overflow: hidden; 
    box-sizing: border-box;
    display: flex;
    justify-content: center;
}

/* Handles desktop offsets cleanly via alignment thresholds */
.menu-links-wrapper {
    width: 100%;
    max-width: 928px;
    padding-right: 250px; 
    box-sizing: border-box;
    position: relative;
    z-index: 2;
    text-align: center;
}

.menu-spacer-element {
    height: 75px; 
}

/* Locks the lotus flower overlay cleanly into the bottom right bounds */
.lotus-decorative-box {
    position: absolute;
    bottom: 0px; 
    right: 0px;
    width: 410px;
    height: 300px;
    overflow: hidden;
    z-index: 1; 
}
.lotus-photo-asset {
    width: auto;
    height: auto;
    margin-left: -555px;
    margin-top: -740px;
    display: block;
}

/* ==========================================
   3. MOBILE RESPONSIVENESS OVERRIDES
   ========================================== */
@media screen and (max-width: 768px) {
    table, .header-outer-table, .header-inner-table {
        width: 100% !important;
        display: block;
    }
    
    tbody, tr, td {
        display: block;
        width: 100% !important;
        box-sizing: border-box;
    }

    /* Fixed Mobile Logo scaling configurations */
    .logo-column {
        display: flex !important;
        justify-content: center !important;
        width: 100% !important;
    }
    .logo-crop-box {
        width: 100px !important;
        height: 85px !important;
        margin: 10px auto 0 auto !important;
        position: relative;
    }
    .site-logo-img {
        width: 520px !important; 
        max-width: none !important;
        height: auto !important;
        position: absolute;
        top: 0px !important;
        left: 0px !important;
        margin: 0 !important;
    }

    /* Tighten typography gap spacing above language strip */
    .header-inner-table td {
        text-align: center !important;
        padding: 0 !important;
    }
    h1 {
        font-size: 18px !important;
        padding: 0 15px !important;
        margin: 5px auto 0 auto !important;
        line-height: 1.3 !important;
    }
    h1 br {
        display: none !important; 
    }
    .main-title-text {
        font-size: 18px !important;
    }
    .main-title-text-chn {
        font-size: 18px !important;
        display: block;
        margin-top: 5px;
    }

    /* Keep switcher links right-aligned inside mobile layouts */
    .language-bar-strip {
        display: block !important;
        text-align: right !important;
    }
    .language-bar-strip p { 
        margin: 0 !important; 
        padding: 5px 15px 5px 0 !important; 
        text-align: right !important;
    }

    /* Responsive scaling tracking parameters for main banner image */
    .temple-banner-frame {
        width: 100% !important;
        height: auto !important;
        aspect-ratio: 928 / 336; 
        margin-top: 10px;
    }
    .temple-photo-asset {
        margin-top: -21%; 
    }

    /* Main body background extends to fit full mobile screens */
    .menu-content-block {
        width: 100% !important;
        height: auto !important;
        flex-direction: column;
        align-items: center;
    }

    /* Strips desktop offsets so links text centers nicely on phones */
    .menu-links-wrapper {
        padding-right: 0 !important;
        text-align: center !important;
        width: 100% !important;
    }

    .menu-spacer-element {
        height: 25px; 
    }

    h2.homepage {
        font-size: 22px !important;
        margin-bottom: 12px;
    }
    a.homepage:link, a.homepage:visited { font-size: 22px !important; }

    /* FLUID MOBILE LOTUS: Uses a tight clip-path matrix mask bounding box. 
       This cuts out the flower bloom natively while making margins 100% transparent. */
    .lotus-decorative-box {
        position: relative !important;
        width: 250px !important;
        height: 200px !important;
        right: auto !important;
        bottom: auto !important;
        overflow: hidden !important;
        background-color: transparent !important;
    }
    .lotus-photo-asset {
        width: 615px !important; 
        max-width: none !important;
        height: auto !important;
        position: absolute;
        margin: 0 !important;
        left: -338px !important; 
        top: -438px !important;  
        /* Stencil mask hides all yellow desktop border leakage */
        clip-path: inset(1px 1px 1px 1px); 
    }

    div.imageright, div.imageleft { float: none !important; margin: 15px auto !important; width: 100% !important; }
    div.imagecentre { width: 100% !important; }

    /* ==========================================
       3b. SUBPAGE (inner page) RESPONSIVENESS
       Applies to pages like LatestNews, Events, etc.
       that use the text-based nav bar layout.
       ========================================== */

    /* Purely decorative desktop-only spacer cells (blockquote
       indents, nbsp padding columns) just eat vertical space
       once tables collapse to blocks on mobile - drop them. */
    .spacer-cell {
        display: none !important;
    }

    /* Text nav bar (Home | About Us | ... ) centers and wraps
       naturally instead of trying to hold one long desktop line. */
    .subpage-nav-links {
        text-align: center !important;
        padding: 8px 10px !important;
    }
    .subpage-nav-links p {
        margin: 0 !important;
    }

    /* Key dates list: each event becomes a stacked card-like
       row instead of a 3-column table row. */
    .key-dates-table .event-row {
        padding: 10px 15px !important;
        border-bottom: 1px solid #d8d2a0;
        text-align: left !important;
    }
    .key-dates-table .event-row:last-child {
        border-bottom: none;
    }
    .key-dates-table .event-date {
        display: block !important;
        font-weight: bold;
        margin-bottom: 2px;
    }

    /* Inline images (e.g. event posters) shouldn't overflow narrow screens */
    img {
        max-width: 100% !important;
        height: auto !important;
    }

    /* Embedded videos (e.g. AboutUs) often carry a fixed desktop
       width/height attribute - constrain those too. */
    video {
        max-width: 100% !important;
        height: auto !important;
    }
}

/* ==========================================
   3c. EVENT POSTER IMAGE (e.g. Guanyin2026eng.png)
   Dedicated class so sizing isn't dependent on a bare
   `img` selector, which is easy for other rules to override.
   Works at ALL screen sizes, not just the mobile breakpoint,
   so a too-wide source image never forces horizontal scroll.
   ========================================== */
.event-poster-img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
}

/* Dedicated class mirroring .event-poster-img, for embedded
   videos that carry a fixed desktop width/height attribute
   (e.g. AboutUs). Works at all screen sizes. */
.responsive-video {
    max-width: 100%;
    height: auto;
}

/* ==========================================
   3d. MOBILE HAMBURGER NAV MENU
   Desktop keeps the original inline text nav bar
   untouched. Under 768px, the link list collapses
   behind a tap-to-expand three-bar icon.
   ========================================== */

/* Hidden on desktop - the button only ever appears on mobile */
.nav-toggle-btn {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 42px;
    height: 36px;
    margin: 0;
    padding: 0;
    background-color: #ffffff;
    border: 1px solid #999999;
    border-radius: 4px;
    cursor: pointer;
}
.nav-toggle-bar {
    display: block;
    width: 22px;
    height: 3px;
    background-color: #000000;
    border-radius: 2px;
    transition: transform 0.2s ease, opacity 0.2s ease;
}
/* Morph the three bars into an X once expanded */
.nav-toggle-btn.nav-toggle-active .nav-toggle-bar:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
}
.nav-toggle-btn.nav-toggle-active .nav-toggle-bar:nth-child(2) {
    opacity: 0;
}
.nav-toggle-btn.nav-toggle-active .nav-toggle-bar:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
}

@media screen and (max-width: 768px) {
    /* Turn the nav row into a flex row so the toggle button
       and language link sit side by side instead of stacking -
       this is what keeps the collapsed bar short. Scoped to
       .subpage-nav-table so it never touches Home.htm's own
       (unrelated) use of .language-bar-strip. */
    .subpage-nav-table tr {
        display: flex !important;
        flex-wrap: wrap !important;
        align-items: center !important;
        width: 100% !important;
    }

    .subpage-nav-table .nav-toggle-cell {
        display: block !important;
        order: 1;
        flex: 0 0 auto !important;
        width: auto !important;
        text-align: left !important;
        padding: 8px 8px 8px 15px !important;
    }
    .subpage-nav-table .nav-toggle-btn {
        display: flex !important;
        margin: 0 !important;
    }

    /* Language link moves to the right edge of the same row */
    .subpage-nav-table .language-bar-strip {
        order: 2;
        flex: 0 0 auto !important;
        width: auto !important;
        margin-left: auto !important;
        padding: 8px 15px 8px 8px !important;
    }

    /* Link list is collapsed by default; JS toggles .nav-open.
       flex-basis 100% drops it onto its own full-width line
       below the toggle/language row once expanded. */
    .subpage-nav-table .subpage-nav-links {
        order: 3;
        flex: 1 1 100% !important;
        width: 100% !important;
        display: none !important;
    }
    .subpage-nav-table .subpage-nav-links.nav-open {
        display: block !important;
        text-align: left !important;
        padding: 0 0 8px 0 !important;
    }
    .subpage-nav-table .subpage-nav-links p {
        margin: 0 !important;
    }
    /* Each link becomes its own full-width tappable row */
    .subpage-nav-table .subpage-nav-links.nav-open a.navblack {
        display: block !important;
        padding: 10px 15px !important;
        border-bottom: 1px solid #aaaaaa;
        text-align: left !important;
    }
    .subpage-nav-table .subpage-nav-links.nav-open a.navblack:last-of-type {
        border-bottom: none;
    }
    /* The " | " separators only make sense on a single desktop line */
    .nav-sep {
        display: none !important;
    }
}

/* ==========================================
   3e. GENERAL CONTENT PAGE HELPERS
   Reusable helpers for content-heavy subpages
   like AboutUs, Events, etc.
   ========================================== */

/* Wrap runs of <br> tags used to clear desktop floats (e.g.
   after a pair of imageleft/imageright divs) in this class.
   On mobile the floats they're clearing are already disabled
   (float:none), so the same <br> run just becomes a large
   empty gap - hide it there, keep it on desktop. */
@media screen and (max-width: 768px) {
    .float-clear-spacer {
        display: none !important;
    }
}

figure {
	text-align: center;
}

/* ==========================================
   3f. TEXT + FLOATED IMAGE LAYOUT
   For subpages like Objectives where desktop shows
   text wrapping around a floated image. On mobile,
   the two stack instead - text always first, image
   centered below it - regardless of source order.
   ========================================== */
@media screen and (max-width: 768px) {
    .side-image-layout {
        display: flex !important;
        flex-direction: column !important;
    }
    .side-image-copy {
        order: 2;
    }
    .side-image-photo {
        order: 1;
        margin-top: 15px;
    }
    .side-image-photo img {
        float: none !important;
        display: block !important;
        margin: 0 auto !important;
        max-width: 100% !important;
        height: auto !important;
    }
}

/* ==========================================
   5. PHOTO GALLERY LIGHTBOX
   Full-screen viewer for the Events page thumbnail
   links, with Prev/Next navigation, keyboard arrows,
   swipe support, and a close button. Paired with
   photo-gallery.js - see that file for the grouping
   logic (no HTML changes needed per page).
   ========================================== */
.photo-gallery-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    z-index: 9999;
    align-items: center;
    justify-content: center;
}
.photo-gallery-modal.pgm-open {
    display: flex;
}
body.pgm-noscroll {
    overflow: hidden;
}
.pgm-content {
    max-width: 92vw;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.pgm-image {
    max-width: 92vw;
    max-height: 80vh;
    display: block;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.6);
}
.pgm-caption {
    color: #ffffff;
    font-family: Verdana, Arial, sans-serif;
    font-size: 14px;
    text-align: center;
    margin-top: 12px;
    max-width: 80vw;
}
.pgm-counter {
    color: #cccccc;
    font-family: Verdana, Arial, sans-serif;
    font-size: 13px;
    margin-top: 6px;
}
.pgm-close, .pgm-prev, .pgm-next {
    position: absolute;
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
    padding: 0;
}
.pgm-close:hover, .pgm-prev:hover, .pgm-next:hover {
    background: rgba(255, 255, 255, 0.3);
}
.pgm-close {
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    font-size: 26px;
    border-radius: 50%;
    line-height: 1;
}
.pgm-prev, .pgm-next {
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    font-size: 20px;
    border-radius: 50%;
}
.pgm-prev { left: 16px; }
.pgm-next { right: 16px; }

@media screen and (max-width: 768px) {
    .pgm-close {
        top: 10px;
        right: 10px;
        width: 36px;
        height: 36px;
        font-size: 22px;
    }
    .pgm-prev, .pgm-next {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
    .pgm-prev { left: 8px; }
    .pgm-next { right: 8px; }
    .pgm-image {
        max-height: 70vh;
    }
	
	img.thumb {
		max-width: 20% !important;
		padding-bottom: 10px;
	}
}

/* ==========================================
   4. LIGHTBOX & OVERLAY CODE (Preserved)
   ========================================== */
#lightbox{ background-color:#eee; padding: 10px; border-bottom: 2px solid #666; border-right: 2px solid #666; }
#lightboxDetails{ font-size: 0.8em; padding-top: 0.4em; }	
#lightboxCaption{ float: left; }
#keyboardMsg{ float: right; }
#closeButton{ top: 5px; right: 5px; }
#lightbox img{ border: none; clear: both;}
#overlay img{ border: none; }
#overlay{ background-image: url(overlay.png); }
a.img:link img, a.img:visited img, a.img:hover img { color: transparent; border-color: transparent; vertical-align: top; }

/* 1. Style the parent wrapper */
.responsive-iframe-container {
  position: relative;
  width: 100%;
  height: 0;
  overflow: hidden;
  /* Calculate aspect ratio: (350 / 425) * 100 = 82.35% */
  padding-bottom: 82.35%; 
}

/* 2. Force the iframe to fill the wrapper */
.responsive-iframe-container iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}