/* main.css - Core styling for I Ching Divination */

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Color Palette */
    --primary-bg: #1a1a2e;
    --secondary-bg: #16213e;
    --tertiary-bg: #0f3460;
    --accent-gold: #ffd700;
    --accent-gold-dim: #ffed4e;
    --text-primary: #e0e0e0;
    --text-secondary: #b0b0b0;
    --text-dim: #808080;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --shadow-dark: rgba(0, 0, 0, 0.3);
    --shadow-glow: rgba(102, 126, 234, 0.4);

    /* Spacing */
    --spacing-xs: 5px;
    --spacing-sm: 10px;
    --spacing-md: 20px;
    --spacing-lg: 30px;
    --spacing-xl: 40px;

    /* Typography */
    --font-main: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-size-base: 16px;
    --line-height: 1.6;

    /* Transitions */
    --transition-fast: 0.3s ease;
    --transition-medium: 0.5s ease;
    --transition-slow: 0.8s ease;
}

body {
    font-family: var(--font-main);
    background: linear-gradient(135deg, var(--primary-bg) 0%, var(--secondary-bg) 50%, var(--tertiary-bg) 100%);
    color: var(--text-primary);
    min-height: 100vh;
    padding: var(--spacing-md);
    position: relative;
    overflow-x: hidden;
    font-size: var(--font-size-base);
    line-height: var(--line-height);
}

/* Background Stars Effect */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        radial-gradient(2px 2px at 20% 30%, white, transparent),
        radial-gradient(2px 2px at 60% 70%, white, transparent),
        radial-gradient(1px 1px at 50% 50%, white, transparent);
    background-size: 200px 200px;
    opacity: 0.1;
    pointer-events: none;
    z-index: -1;
}

/* Container */
.container {
    max-width: 900px;
    margin: 0 auto;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: var(--spacing-xl);
    box-shadow: 0 25px 45px var(--shadow-dark);
    border: 1px solid var(--glass-border);
}

/* Typography */
h1 {
    text-align: center;
    color: #f0f0f0;
    margin-bottom: var(--spacing-xl);
    font-size: 3em;
    font-weight: 300;
    letter-spacing: 2px;
    position: relative;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
}

h1::after {
    content: '☯';
    display: block;
    font-size: 0.5em;
    margin-top: var(--spacing-sm);
    opacity: 0.6;
}

h3,
h4 {
    margin-top: var(--spacing-lg);
    margin-bottom: var(--spacing-md);
}

h3 {
    color: var(--accent-gold);
    font-size: 1.4em;
}

h4 {
    color: var(--text-secondary);
    font-size: 1.2em;
}

/* Form Elements */
.input-group {
    margin-bottom: var(--spacing-lg);
    position: relative;
}

label {
    display: block;
    margin-bottom: var(--spacing-sm);
    color: var(--text-secondary);
    font-size: 1.1em;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 300;
}

input[type="text"],
textarea {
    width: 100%;
    padding: 15px 20px;
    border: none;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    font-size: 1.1em;
    transition: var(--transition-fast);
    border: 1px solid var(--glass-border);
    font-family: inherit;
}

input[type="text"]:focus,
textarea:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.12);
    box-shadow: 0 0 30px rgba(100, 200, 255, 0.3);
    border-color: rgba(100, 200, 255, 0.5);
    transform: scale(1.02);
}

textarea {
    resize: vertical;
    min-height: 100px;
}

/* Buttons */
button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 15px 40px;
    border-radius: 30px;
    font-size: 1.2em;
    cursor: pointer;
    transition: var(--transition-fast);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 500;
    position: relative;
    overflow: hidden;
    margin: var(--spacing-sm);
    box-shadow: 0 5px 15px var(--shadow-glow);
}

button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s ease;
}

button:hover::before {
    left: 100%;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.6);
}

button:active {
    transform: translateY(0);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.button-container {
    text-align: center;
    margin: var(--spacing-lg) 0;
}

/* Language Selector */
.language-selector {
    position: absolute;
    top: var(--spacing-md);
    right: var(--spacing-md);
    display: flex;
    gap: var(--spacing-sm);
    z-index: 100;
}

.language-btn {
    padding: 8px 16px;
    background: var(--glass-bg);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition-fast);
    font-size: 14px;
}

.language-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.language-btn.active {
    background: rgba(102, 126, 234, 0.6);
    border-color: rgba(102, 126, 234, 0.8);
}

/* Hexagram Display */
.hexagram-display {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: var(--spacing-xl) 0;
    min-height: 300px;
    position: relative;
}

.hexagram-container {
    display: flex;
    gap: 50px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}

.hexagram {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: var(--spacing-lg);
    background: var(--glass-bg);
    border-radius: 15px;
    box-shadow: 0 10px 30px var(--shadow-dark);
    position: relative;
    transition: var(--transition-medium);
}

.hexagram.active {
    box-shadow: 0 10px 40px var(--shadow-glow);
}

.hexagram.changing-hexagram {
    opacity: 0.7;
}

/* Hexagram Lines */
.line {
    height: 12px;
    width: 200px;
    position: relative;
    opacity: 0;
}

.line.yang {
    background: linear-gradient(90deg, var(--accent-gold), var(--accent-gold-dim));
    box-shadow: 0 2px 10px rgba(255, 215, 0, 0.5);
}

.line.yin {
    background: transparent;
    display: flex;
    gap: 20px;
    justify-content: center;
}

.yin-left,
.yin-right {
    flex: 1;
    height: 100%;
    background: linear-gradient(90deg, #a0a0a0, #b0b0b0);
    box-shadow: 0 2px 10px rgba(160, 160, 160, 0.3);
}

.line.moving .changing-indicator {
    position: absolute;
    right: -30px;
    top: 50%;
    transform: translateY(-50%);
    color: #ff6b6b;
    font-size: 20px;
}

/* Hexagram Info */
.hexagram-info {
    text-align: center;
    margin-top: var(--spacing-md);
    opacity: 0;
}

.hexagram-name {
    font-size: 1.8em;
    color: var(--accent-gold);
    margin-bottom: var(--spacing-sm);
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.changing-name {
    font-size: 1.4em;
}

.trigram-info {
    display: flex;
    justify-content: center;
    gap: var(--spacing-lg);
    margin: var(--spacing-md) 0;
    flex-wrap: wrap;
}

.trigram-box {
    background: rgba(255, 255, 255, 0.08);
    padding: 15px 25px;
    border-radius: 10px;
    text-align: center;
    border: 1px solid rgba(255, 215, 0, 0.3);
}

.trigram-label {
    font-size: 0.9em;
    color: #888;
    margin-bottom: 5px;
}

.trigram-name {
    font-size: 1.2em;
    color: var(--accent-gold);
}

.trigram-element {
    font-size: 1.5em;
    margin-top: 5px;
    opacity: 0.7;
}

/* Interpretation Section */
.interpretation {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 15px;
    padding: var(--spacing-lg);
    margin: var(--spacing-lg) 0;
    line-height: 1.8;
    font-size: 1.1em;
    color: var(--text-primary);
    text-align: justify;
    opacity: 0;
    box-shadow: 0 10px 30px var(--shadow-dark);
}

.interpretation p {
    margin-bottom: var(--spacing-md);
}

.interpretation strong {
    color: var(--accent-gold);
    font-weight: 600;
}

/* Changing Info */
.changing-info {
    margin-top: var(--spacing-md);
    padding-top: var(--spacing-md);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.changing-label {
    color: var(--text-dim);
    margin-bottom: var(--spacing-xs);
}

/* Plum Blossom Info */
.plum-blossom-info {
    margin-top: var(--spacing-md);
    padding: var(--spacing-md);
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

.time-calculation {
    font-size: 0.9em;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-sm);
}

.ti-yong-info {
    display: flex;
    justify-content: center;
    gap: var(--spacing-lg);
}

.ti-label,
.yong-label {
    padding: 5px 15px;
    background: rgba(255, 215, 0, 0.1);
    border-radius: 15px;
    font-size: 0.9em;
}

/* Save Container */
.save-container {
    text-align: center;
    margin-top: var(--spacing-xl);
}

/* Loading Indicator */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
    margin-left: var(--spacing-sm);
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Hidden Elements */
.hidden {
    display: none;
}

/* Canvas (for export) */
#downloadCanvas {
    display: none;
}

/* Coin Animation Container */
.coins-animation {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
    z-index: 1000;
}

.coin {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-gold), var(--accent-gold-dim));
    box-shadow: 0 5px 20px rgba(255, 215, 0, 0.6);
    position: absolute;
    animation: flip 0.8s ease-in-out;
}

.coin:nth-child(1) {
    left: -100px;
}

.coin:nth-child(2) {
    left: 0;
}

.coin:nth-child(3) {
    left: 100px;
}

/* Life Area Interpretations */
.life-areas {
    margin-top: var(--spacing-lg);
}

.interpretation-section {
    background: rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-md);
    border-left: 4px solid var(--accent-gold);
    transition: var(--transition-fast);
}

.interpretation-section:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateX(5px);
}

.interpretation-section h4 {
    color: var(--accent-gold);
    margin-bottom: var(--spacing-sm);
    font-size: 1.2em;
    display: flex;
    align-items: center;
}

.interpretation-section h4::before {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    margin-right: var(--spacing-sm);
    background-size: contain;
    opacity: 0.8;
}

/* Icons for each life area */
.interpretation-section:nth-child(1) h4::before {
    /* Career */
    content: '💼';
}

.interpretation-section:nth-child(2) h4::before {
    /* Relationships */
    content: '❤️';
}

.interpretation-section:nth-child(3) h4::before {
    /* Health */
    content: '🌱';
}

.interpretation-section:nth-child(4) h4::before {
    /* Wealth */
    content: '💰';
}

.interpretation-section:nth-child(5) h4::before {
    /* Timing */
    content: '⏰';
}

.interpretation-section:nth-child(6) h4::before {
    /* Advice */
    content: '💡';
}

.changing-guidance {
    background: rgba(102, 126, 234, 0.1);
    border-left-color: rgba(102, 126, 234, 0.8);
}

.changing-guidance h4::before {
    content: '🔄';
}

/* Utility Classes */
.text-center {
    text-align: center;
}

.text-left {
    text-align: left;
}

.text-right {
    text-align: right;
}

.mt-sm {
    margin-top: var(--spacing-sm);
}

.mt-md {
    margin-top: var(--spacing-md);
}

.mt-lg {
    margin-top: var(--spacing-lg);
}

.mb-sm {
    margin-bottom: var(--spacing-sm);
}

.mb-md {
    margin-bottom: var(--spacing-md);
}

.mb-lg {
    margin-bottom: var(--spacing-lg);
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}