/**
 * 真正的中國古代風格 (Authentic Ancient Chinese Style)
 * Redesigned for AI Fortune Telling
 */

/* ================================
   CSS Variables - 設計變數
   ================================ */
:root {
    /* 顏色 - 中國傳統配色 */
    --ancient-red: #8B1A1A;
    /* 朱紅 - Vermilion */
    --ancient-red-light: #CD5C5C;
    /* 淡朱紅 */
    --ancient-red-dark: #5C1010;
    /* 深朱紅 */
    --ancient-gold: #D4AF37;
    /* 金黃 - Gold */
    --ancient-gold-light: #F4D03F;
    /* 亮金 */
    --ancient-gold-dark: #B8860B;
    /* 深金 */
    --ancient-ink: #2B2B2B;
    /* 墨黑 - Ink Black (Softer than pure black) */
    --ancient-ink-light: #4A4A4A;
    /* 淡墨 */
    --ancient-brown: #5D4037;
    /* 深褐 - Wood/Earth */
    --ancient-jade: #5F9EA0;
    /* 玉綠 - Jade */
    --ancient-paper: #F5E6D3;
    /* 宣紙 - Rice Paper */

    /* 背景色 */
    --bg-primary: #F5E6D3;
    /* 主背景 */
    --bg-secondary: #FDF5E6;
    /* 次背景 (卡片等) */
    --bg-dark: #E8D5B7;
    /* 深色背景 (頁尾等) */
    --bg-overlay: rgba(255, 255, 255, 0.85);

    /* 字體 */
    --font-serif: 'Noto Serif TC', 'PMingLiU', 'MingLiU', serif;
    --font-kai: 'Ma Shan Zheng', 'STKaiti', 'KaiTi', 'BiauKai', serif;
    /* Calligraphy style */
    --font-sans: 'Noto Sans TC', sans-serif;
    /* For small readable text */

    /* 間距 */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    --space-3xl: 4rem;

    /* 邊框 */
    --border-width: 2px;
    --border-style: solid;
    --border-color: #8B4513;
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 16px;

    /* 陰影 */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.2);
    --shadow-gold: 0 0 15px rgba(212, 175, 55, 0.3);

    /* 動畫 */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
}

/* ================================
   Reset & Base Styles
   ================================ */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-serif);
    background-color: var(--bg-primary);
    background-image: url("data:image/svg+xml,%3Csvg width='200' height='200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.08'/%3E%3C/svg%3E");
    color: var(--ancient-ink);
    line-height: 1.6;
    overflow-x: hidden;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-kai);
    color: var(--ancient-red-dark);
    margin-bottom: var(--space-md);
    font-weight: normal;
}

a {
    color: var(--ancient-red);
    text-decoration: none;
    transition: var(--transition-fast);
}

a:hover {
    color: var(--ancient-red-light);
}

ul {
    list-style: none;
}

/* ================================
   Layout Components
   ================================ */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--space-md);
}

/* Navbar - Scroll Style */
.navbar {
    background: var(--bg-secondary);
    border-bottom: 4px double var(--ancient-red);
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 1000;
    padding: var(--space-sm) 0;
    width: 100%;
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: nowrap;
    /* Prevent wrapping */
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex-shrink: 0;
    /* Prevent shrinking */
}

.nav-brand h1 {
    margin: 0;
    font-size: 1.8rem;
    color: var(--ancient-red-dark);
    white-space: nowrap;
    /* Prevent text wrapping */
}

.nav-menu {
    display: flex;
    gap: var(--space-lg);
    align-items: center;
    margin: 0;
    padding: 0;
    flex-wrap: nowrap;
    /* Prevent wrapping */
}

.nav-menu li {
    flex-shrink: 0;
    /* Prevent items from shrinking */
}

.nav-menu li a {
    font-size: 1.1rem;
    color: var(--ancient-ink);
    padding: var(--space-xs) var(--space-sm);
    position: relative;
    white-space: nowrap;
    /* Prevent text wrapping */
    display: block;
}

.nav-menu li a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: var(--ancient-red);
    transition: var(--transition-normal);
    transform: translateX(-50%);
}

.nav-menu li a:hover::after,
.nav-menu li a.active::after {
    width: 80%;
}

.nav-menu li a.active {
    color: var(--ancient-red);
    font-weight: bold;
}

/* Language Switcher */
.lang-switcher {
    position: relative;
    z-index: 1002;
    /* Ensure it's above other things */
}

.lang-btn {
    background: transparent;
    border: 1px solid var(--ancient-brown);
    color: var(--ancient-brown);
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-family: var(--font-serif);
    display: flex;
    align-items: center;
    gap: 5px;
    transition: var(--transition-fast);
    white-space: nowrap;
}

.lang-btn:hover {
    background: var(--ancient-brown);
    color: var(--bg-secondary);
}

.lang-menu {
    display: none;
    /* Hidden by default */
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--ancient-brown);
    box-shadow: var(--shadow-md);
    margin-top: 5px;
    min-width: 120px;
    z-index: 1003;
    border-radius: 4px;
    overflow: hidden;
    padding: 0;
}

/* Ensure it's visible when active class is added (if we used that) */
.lang-menu.show {
    display: block;
}

.lang-menu li {
    display: block;
    width: 100%;
}

.lang-menu li a {
    display: block;
    padding: 8px 12px;
    color: var(--ancient-ink);
    transition: background 0.2s;
    text-align: left;
}

.lang-menu li a:hover {
    background: var(--ancient-paper);
    color: var(--ancient-red);
}

/* Hero Section */
.hero {
    padding: var(--space-3xl) 0;
    text-align: center;
    background: radial-gradient(circle at center, var(--bg-secondary) 0%, var(--bg-primary) 100%);
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 10px;
    background-image: linear-gradient(90deg, var(--ancient-gold) 50%, transparent 50%);
    background-size: 40px 100%;
    opacity: 0.5;
}

.hero-title {
    font-size: 3.5rem;
    margin-bottom: var(--space-lg);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.hero-subtitle {
    font-size: 1.5rem;
    color: var(--ancient-ink-light);
    margin-bottom: var(--space-xl);
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

/* Buttons - Seal Style */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: 12px 30px;
    font-family: var(--font-kai);
    font-size: 1.2rem;
    border: 2px solid transparent;
    cursor: pointer;
    transition: var(--transition-normal);
    text-decoration: none;
    position: relative;
}

.btn-primary {
    background-color: var(--ancient-red);
    color: #fff;
    border-color: var(--ancient-red-dark);
    box-shadow: var(--shadow-md);
}

.btn-primary:hover {
    background-color: var(--ancient-red-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    color: #fff;
}

.btn-secondary {
    background-color: transparent;
    border-color: var(--ancient-red);
    color: var(--ancient-red);
}

.btn-secondary:hover {
    background-color: rgba(139, 26, 26, 0.1);
    transform: translateY(-2px);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--ancient-brown);
    color: var(--ancient-brown);
}

.btn-outline:hover {
    background: var(--ancient-brown);
    color: #fff;
}

/* Cards - Rice Paper Style */
.card {
    background: var(--bg-secondary);
    padding: var(--space-xl);
    border: 1px solid rgba(139, 69, 19, 0.2);
    box-shadow: var(--shadow-sm);
    position: relative;
    transition: var(--transition-normal);
}

.card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-3px);
    border-color: var(--ancient-gold);
}

.card::before {
    content: '';
    position: absolute;
    top: 4px;
    left: 4px;
    right: 4px;
    bottom: 4px;
    border: 1px solid rgba(139, 69, 19, 0.1);
    pointer-events: none;
}

.card-title {
    font-size: 1.5rem;
    text-align: center;
    margin-bottom: var(--space-lg);
    color: var(--ancient-red-dark);
    border-bottom: 1px solid rgba(139, 26, 26, 0.2);
    padding-bottom: var(--space-sm);
}

/* Grid System */
.grid {
    display: grid;
    gap: var(--space-lg);
}

.grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 768px) {

    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
    }
}

/* Section Styling */
.section {
    padding: var(--space-3xl) 0;
}

.section-header {
    text-align: center;
    margin-bottom: var(--space-2xl);
}

.section-title {
    font-size: 2.5rem;
    color: var(--ancient-red-dark);
    position: relative;
    display: inline-block;
}

.section-title::before,
.section-title::after {
    content: '✦';
    color: var(--ancient-gold);
    margin: 0 var(--space-sm);
    font-size: 1.5rem;
    vertical-align: middle;
}

.section-subtitle {
    font-size: 1.1rem;
    color: var(--ancient-ink-light);
    margin-top: var(--space-sm);
}

/* Seal Element */
.seal {
    width: 60px;
    height: 60px;
    background: var(--ancient-red);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-kai);
    font-size: 2rem;
    border-radius: 4px;
    border: 2px solid var(--ancient-red-dark);
    box-shadow: var(--shadow-sm);
    position: relative;
}

.seal::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    right: 2px;
    bottom: 2px;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

/* Footer */
.footer {
    background: var(--bg-dark);
    padding: var(--space-xl) 0;
    text-align: center;
    border-top: 4px double var(--ancient-brown);
    margin-top: var(--space-3xl);
}

.footer p {
    color: var(--ancient-ink-light);
}

/* Form Elements */
.form-group {
    margin-bottom: var(--space-lg);
}

.form-label {
    display: block;
    margin-bottom: var(--space-sm);
    font-weight: bold;
    color: var(--ancient-brown);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 12px;
    background: #fff;
    border: 2px solid var(--ancient-brown);
    border-radius: 0;
    /* Traditional look */
    font-family: var(--font-serif);
    font-size: 1rem;
    transition: var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--ancient-red);
    box-shadow: 0 0 0 3px rgba(139, 26, 26, 0.1);
}

/* Utility Classes */
.text-center {
    text-align: center;
}

.mb-lg {
    margin-bottom: var(--space-lg);
}

.mt-lg {
    margin-top: var(--space-lg);
}

.hidden {
    display: none;
}

/* Loading Spinner */
.spinner {
    border: 4px solid rgba(0, 0, 0, 0.1);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border-left-color: var(--ancient-red);
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}