/* 
 * Shihlin Rotary Club - Visionary Design System v1.0
 * Theme: International, Trust, Warmth, Professional
 */

:root {
    /* -------------------------------------
       Color Palette 
       ------------------------------------- */
    /* Primary */
    --color-primary-dark: #00205b;
    /* Deep Navy - Authority, Trust */
    --color-primary: #0033a0;
    /* Royal Blue - Rotary Brand */
    --color-primary-light: #4c72b0;

    /* Secondary / Accent */
    --color-gold: #c5a059;
    /* Elegant Gold - Honor */
    --color-gold-light: #e5c585;
    --color-accent-red: #d92131;
    /* Rotary Action Red */

    /* Neutrals */
    --color-text-main: #2d3748;
    --color-text-light: #718096;
    --color-bg-body: #f7f9fb;
    /* Very Light Blue/Gray tint for richness */
    --color-white: #ffffff;
    --color-border: #e2e8f0;

    /* -------------------------------------
       Typography 
       ------------------------------------- */
    --font-heading: 'Outfit', 'Helvetica Neue', sans-serif;
    --font-body: 'Inter', system-ui, sans-serif;
    --font-serif: 'Noto Serif TC', serif;
    /* For elegant quotes */

    /* -------------------------------------
       Spacing & Layout 
       ------------------------------------- */
    --container-width: 1280px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 32px;
    --spacing-xl: 64px;
    --spacing-xxl: 96px;

    --grid-gap: 24px;
    --header-height: 80px;

    /* -------------------------------------
       Effects 
       ------------------------------------- */
    --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 16px;

    --transition-base: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* -------------------------------------
   Reset & Base 
   ------------------------------------- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-body);
    color: var(--color-text-main);
    background-color: var(--color-bg-body);
    line-height: 1.6;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    padding-top: var(--header-height);
    /* Offset fixed header */
    overflow-x: hidden;
    /* Prevent horizontal scroll from full-width elements */
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-heading);
    color: var(--color-primary-dark);
    line-height: 1.25;
    margin-bottom: 1rem;
    font-weight: 700;
}

h1 {
    font-size: clamp(2.5rem, 5vw, 3.5rem);
    letter-spacing: -0.02em;
}

h2 {
    font-size: clamp(2rem, 4vw, 2.5rem);
    letter-spacing: -0.01em;
}

h3 {
    font-size: 1.75rem;
}

h4 {
    font-size: 1.5rem;
}

h5 {
    font-size: 1.25rem;
}

a {
    color: inherit;
    text-decoration: none;
    transition: var(--transition-base);
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* -------------------------------------
   Layout Utilities 
   ------------------------------------- */
.container {
    width: 90%;
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0 var(--spacing-md);
}

.section-padding {
    padding: var(--spacing-xl) 0;
}

.grid {
    display: grid;
    gap: var(--grid-gap);
}

.grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

/* Responsive Grid */
@media (max-width: 1024px) {
    .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {

    .grid-3,
    .grid-2 {
        grid-template-columns: 1fr;
    }

    .grid-4 {
        grid-template-columns: 1fr;
    }
}

.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-sm {
    gap: var(--spacing-sm);
}

.gap-md {
    gap: var(--spacing-md);
}

/* -------------------------------------
   Specific Layouts 
   ------------------------------------- */
.sidebar-layout {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: var(--spacing-xl);
}

.about-hero-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
    align-items: start;
}

@media (max-width: 900px) {
    .sidebar-layout {
        grid-template-columns: 1fr;
        gap: var(--spacing-md);
    }

    .about-hero-grid {
        grid-template-columns: 1fr;
    }

    /* Reverse order for about-hero-grid on mobile if image needs to be on top? 
       For now, just stacking is fine (text first). */
    .about-hero-grid>div:last-child {
        order: -1;
        /* Put image on top on mobile? 
           The current code has text first, image second. 
           If I stack 1fr, Text is top. 
           Let's keep text top or image top? 
           Let's leave order as is (Text first) for now unless it looks weird.
        */
        margin-bottom: 2rem;
    }
}

.member-detail-grid {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 0;
    align-items: stretch;
}

@media (max-width: 900px) {
    .member-detail-grid {
        grid-template-columns: 1fr;
    }
}

/* -------------------------------------
   Components 
   ------------------------------------- */

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    border-radius: 50px;
    letter-spacing: 0.025em;
    cursor: pointer;
    transition: var(--transition-base);
    border: none;
}

.btn-primary {
    background: var(--color-primary-dark);
    color: var(--color-white);
    box-shadow: 0 4px 10px rgba(0, 32, 91, 0.3);
}

.btn-primary:hover {
    background: var(--color-primary);
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0, 32, 91, 0.4);
}

.btn-secondary {
    background: var(--color-gold);
    color: var(--color-primary-dark);
}

.btn-secondary:hover {
    background: var(--color-gold-light);
    transform: translateY(-2px);
}

.btn-ghost {
    background: transparent;
    color: var(--color-primary-dark);
    border: 1px solid var(--color-primary-dark);
}

.btn-ghost:hover {
    background: rgba(0, 51, 160, 0.05);
    /* slightly tinted */
}

/* Cards */
.card {
    background: var(--color-white);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-card);
    transition: var(--transition-base);
    height: 100%;
    display: flex;
    flex-direction: column;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
}

.card-horizontal {
    display: flex;
    flex-direction: row;
}

@media (max-width: 768px) {
    .card-horizontal {
        flex-direction: column;
    }

    .card-horizontal .card-img-wrapper {
        width: 100% !important;
        height: 200px !important;
    }
}

/* Responsive Table Styles */
@media (max-width: 768px) {
    .responsive-table thead {
        display: none;
    }

    .responsive-table tr {
        display: block;
        margin-bottom: 1rem;
        background: #fff;
        border: 1px solid var(--color-border);
        border-radius: var(--radius-md);
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    }

    .responsive-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.75rem 1rem;
        border-bottom: 1px solid #eee;
        display: block;
        /* Fallback */
        text-align: right;
        position: relative;
        padding-left: 50%;
    }

    .responsive-table td::before {
        content: attr(data-label);
        position: absolute;
        left: 1rem;
        width: 45%;
        white-space: nowrap;
        text-align: left;
        font-weight: 700;
        color: var(--color-primary-dark);
        top: 0.75rem;
        /* Match padding-top */
    }

    .responsive-table td:last-child {
        border-bottom: none;
        display: flex;
        justify-content: center;
        /* Center the button */
        padding-left: 1rem;
        /* Reset padding */
        padding-top: 1rem;
        padding-bottom: 1rem;
    }

    .responsive-table td:last-child::before {
        content: '';
        /* No label for action button usually, or handle differently */
        display: none;
    }
}

.card-img-wrapper {
    position: relative;
    padding-top: 56.25%;
    /* 16:9 Aspect Ratio */
    overflow: hidden;
}

.card-img-wrapper img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

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

.card-body {
    padding: var(--spacing-md);
    flex: 1;
    display: flex;
    flex-direction: column;
}

.card-meta {
    font-size: 0.875rem;
    color: var(--color-text-light);
    margin-bottom: 0.5rem;
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* Badges */
.badge {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-primary {
    background: rgba(0, 51, 160, 0.1);
    color: var(--color-primary);
}

.badge-gold {
    background: rgba(197, 160, 89, 0.15);
    color: #8a6d2b;
}

/* -------------------------------------
   Header 
   ------------------------------------- */
.site-header {
    background: var(--color-white);
    height: var(--header-height);
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 1000;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.05);
    transition: height 0.3s ease, box-shadow 0.3s ease;
}

.site-header.scrolled {
    height: 60px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.brand-logo img {
    transition: height 0.3s ease;
}

.site-header.scrolled .brand-logo img {
    height: 50px !important;
    /* Scale down when scrolled */
}

.header-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    padding: 0 var(--spacing-md);
    max-width: var(--container-width);
    margin: 0 auto;
}

.brand-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 800;
    font-size: 1.5rem;
    color: var(--color-primary-dark);
}

.brand-logo i {
    color: var(--color-gold);
}

/* Nav */
.main-nav {
    display: none;
}

/* Hidden on mobile by default */

@media (min-width: 1024px) {
    .main-nav {
        display: block;
    }

    .main-nav ul {
        display: flex;
        gap: 2rem;
        list-style: none;
    }

    .main-nav a {
        font-weight: 500;
        color: var(--color-text-main);
        font-size: 0.95rem;
        position: relative;
    }

    .main-nav a:hover {
        color: var(--color-primary);
    }

    .main-nav a::after {
        content: '';
        position: absolute;
        bottom: -4px;
        left: 0;
        width: 0;
        height: 2px;
        background: var(--color-gold);
        transition: width 0.3s;
    }

    .main-nav a:hover::after {
        width: 100%;
    }
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.mobile-toggle {
    font-size: 1.5rem;
    cursor: pointer;
    display: block;
}

@media (min-width: 1024px) {
    .mobile-toggle {
        display: none;
    }
}

/* -------------------------------------
   Footer 
   ------------------------------------- */
.site-footer {
    background: var(--color-primary-dark);
    color: rgba(255, 255, 255, 0.7);
    padding-top: var(--spacing-xl);
}

.footer-logo {
    color: var(--color-white);
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    display: block;
}

.footer-link-list li {
    margin-bottom: 0.5rem;
}

.footer-link-list a:hover {
    color: var(--color-gold);
}

.copyright {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: var(--spacing-md) 0;
    margin-top: var(--spacing-lg);
    text-align: center;
    font-size: 0.875rem;
}

/* -------------------------------------
   Pages: Home Components 
   ------------------------------------- */
.hero {
    height: 85vh;
    min-height: 600px;
    background-color: var(--color-primary-dark);
    position: relative;
    display: flex;
    align-items: center;
    /* margin-top: var(--header-height); removed because body has padding now */
    overflow: hidden;
}

.hero-bg {
    position: absolute;
    inset: 0;
    opacity: 0.4;
    background-size: cover;
    background-position: center;
}

.hero-content {
    position: relative;
    z-index: 10;
    color: var(--color-white);
    max-width: 800px;
}

.hero-title {
    color: var(--color-white);
    font-size: clamp(3rem, 6vw, 4.5rem);
    margin-bottom: 1.5rem;
    line-height: 1.1;
}

.hero-subtitle {
    font-size: 1.25rem;
    opacity: 0.9;
    margin-bottom: 2rem;
    max-width: 600px;
}

/* Tab Component */
.tabs {
    border-bottom: 2px solid var(--color-border);
    margin-bottom: var(--spacing-md);
    display: flex;
    gap: 2rem;
}

.tab-btn {
    background: none;
    border: none;
    padding: 0.5rem 0;
    font-size: 1.1rem;
    color: var(--color-text-light);
    cursor: pointer;
    position: relative;
    font-weight: 500;
}

.tab-btn.active {
    color: var(--color-primary-dark);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--color-primary-dark);
}

/* Calendar Widget */
.calendar-widget {
    background: var(--color-white);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    padding: var(--spacing-md);
}

.cal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--color-border);
}

.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 5px;
    text-align: center;
}

.cal-day {
    padding: 5px;
    font-size: 0.9rem;
}


/* History Page Responsive Styles */
@media (max-width: 768px) {

    /* Intro Table */
    .history-info-table,
    .history-info-table tbody,
    .history-info-table tr,
    .history-info-table td {
        display: block;
        width: 100%;
    }

    .history-info-table tr {
        margin-bottom: 1rem;
        border: 1px solid var(--color-border);
        border-radius: var(--radius-sm);
        overflow: hidden;
    }

    .history-info-table td:first-child {
        background-color: #f8f9fa;
        font-weight: 700;
        border-bottom: 1px solid #eee;
        width: 100% !important;
    }

    /* Sponsored Table */
    .history-sponsored-table,
    .history-sponsored-table tbody,
    .history-sponsored-table tr {
        display: block;
        width: 100%;
    }

    .history-sponsored-table tr {
        border-bottom: 1px solid #eee;
        padding: 0.5rem 0;
    }

    .history-sponsored-table td {
        display: block;
        width: 100% !important;
        padding: 0.25rem 0.5rem !important;
        text-align: left !important;
        border: none !important;
    }

    .history-sponsored-table td:first-child {
        display: none;
        /* Hide the spacer/label column on mobile */
    }

    /* Alliance List */
    .alliance-item {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 0.25rem;
    }
}

/* Responsive Visibility Utilities */
.mobile-only {
    display: none !important;
}

@media (max-width: 768px) {
    .mobile-only {
        display: block !important;
    }

    .desktop-only {
        display: none !important;
    }

    /* Mobile Sidebar Tabs */
    aside {
        position: sticky;
        top: 60px;
        /* Header height */
        z-index: 99;

        /* Full Viewport Width Breakout */
        width: 100vw;
        max-width: 100vw;
        margin-left: calc(50% - 50vw);
        margin-right: calc(50% - 50vw);
        margin-bottom: 1.5rem;

        background: #fff;
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
        border-bottom: 1px solid #eee;
    }

    aside .card {
        border-radius: 0;
        box-shadow: none !important;
        position: static !important;
    }

    aside .card>div:first-child {
        display: none;
        /* Hide '認識本社' title on mobile */
    }

    aside ul {
        display: flex;
        flex-wrap: wrap;
        /* Allow wrapping */
        justify-content: center;
        /* overflow-x: auto;  Removed scrolling */
        /* white-space: nowrap; Removed nowrap */
    }

    aside ul::-webkit-scrollbar {
        display: none;
    }

    aside li {
        border-bottom: none !important;
        flex: 1 1 auto;
        /* Allow sizing based on content and wrapping */
        text-align: center;
    }

    aside a {
        padding: 1rem 0.5rem !important;
        /* Reduced side padding */
        border-left: none !important;
        border-bottom: 3px solid transparent;
        color: var(--color-text-light) !important;
        font-weight: 500 !important;
        font-size: 0.9rem;
        /* Slightly smaller text */
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Active state for mobile tabs */
    aside a[style*="var(--color-primary)"] {
        color: var(--color-primary) !important;
        border-bottom-color: var(--color-primary) !important;
        background: rgba(0, 51, 160, 0.03);
    }
}

/* PP King Card Styles */
.pp-king-card {
    background: #fff8f8;
    padding: 1.5rem;
    border-radius: 8px;
    border-left: 5px solid var(--color-accent-red);
    margin-bottom: 2rem;
}

.pp-king-content {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
}

.pp-king-img {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: 50%;
    border: 3px solid #fff;
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
}

.pp-king-title {
    color: #d92131;
    margin-bottom: 0.5rem;
    font-size: 1.2rem;
}

.pp-king-role {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.pp-king-desc {
    color: #666;
    font-size: 0.95rem;
}

@media (max-width: 600px) {
    .pp-king-content {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .pp-king-img {
        margin-bottom: 0.5rem;
    }
}