/* === I Ching Oracle — Dark Contemplative Aesthetic === */

:root {
    --bg: #0a0a0a;
    --bg-card: #111111;
    --bg-hover: #1a1a1a;
    --text: #d4c5a9;
    --text-dim: #8a7e6a;
    --text-bright: #e8dcc6;
    --accent: #c9a84c;
    --accent-dim: #8a7234;
    --line-yang: #d4c5a9;
    --line-yin: #d4c5a9;
    --line-changing: #c9a84c;
    --border: #2a2520;
    --serif: 'Cormorant Garamond', 'Georgia', serif;
    --chinese: 'Noto Serif SC', serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--serif);
    font-size: 18px;
    line-height: 1.7;
    min-height: 100vh;
}

.container {
    max-width: 680px;
    margin: 0 auto;
    padding: 3rem 1.5rem;
}

/* === Header === */
header {
    text-align: center;
    margin-bottom: 4rem;
}

.title {
    font-family: var(--chinese);
    font-size: 4rem;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 0.3em;
    margin-bottom: 0.25rem;
}

.subtitle {
    font-size: 1.1rem;
    font-weight: 400;
    font-style: italic;
    color: var(--text-dim);
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

/* === Phases === */
.phase {
    display: none;
    animation: fadeIn 0.8s ease;
}

.phase.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* === Question Phase === */
.oracle-prompt {
    text-align: center;
}

.prompt-text {
    font-size: 1.3rem;
    font-style: italic;
    color: var(--text-dim);
    margin-bottom: 2rem;
}

textarea {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-bright);
    font-family: var(--serif);
    font-size: 1.1rem;
    padding: 1.2rem;
    resize: none;
    outline: none;
    transition: border-color 0.3s;
}

textarea:focus {
    border-color: var(--accent-dim);
}

textarea::placeholder {
    color: var(--text-dim);
    font-style: italic;
}

.cast-button {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 2rem;
    padding: 1rem 2.5rem;
    background: transparent;
    border: 1px solid var(--accent-dim);
    border-radius: 4px;
    color: var(--accent);
    font-family: var(--serif);
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.3s;
    letter-spacing: 0.05em;
}

.cast-button:hover {
    background: var(--accent-dim);
    color: var(--bg);
    border-color: var(--accent);
}

.cast-button:active {
    transform: scale(0.98);
}

.btn-icon {
    font-size: 1.3rem;
    opacity: 0.7;
}

.randomness-note {
    margin-top: 1.5rem;
    font-size: 0.8rem;
    color: var(--text-dim);
    font-style: italic;
}

.randomness-note a {
    color: var(--text-dim);
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* === Casting Phase === */
.casting-animation {
    text-align: center;
    padding: 3rem 0;
}

.coins-container {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 2rem;
}

.coin {
    font-size: 3rem;
    color: var(--accent);
    animation: coinSpin 0.6s ease-in-out infinite alternate;
}

.coin:nth-child(2) { animation-delay: 0.2s; }
.coin:nth-child(3) { animation-delay: 0.4s; }

@keyframes coinSpin {
    from { transform: rotateY(0deg) scale(1); opacity: 0.6; }
    to { transform: rotateY(180deg) scale(1.1); opacity: 1; }
}

.casting-text {
    font-size: 1.2rem;
    font-style: italic;
    color: var(--text-dim);
}

.dots {
    animation: ellipsis 1.5s infinite;
}

@keyframes ellipsis {
    0% { content: '.'; }
    33% { content: '..'; }
    66% { content: '...'; }
}

.lines-building {
    margin-top: 2rem;
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
    gap: 8px;
    min-height: 120px;
}

/* === Hexagram Display === */
.hexagram-display {
    text-align: center;
    margin-bottom: 2.5rem;
}

.hexagram-header {
    margin-bottom: 2rem;
}

.hex-number {
    display: inline-block;
    font-size: 0.85rem;
    color: var(--text-dim);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-bottom: 0.5rem;
}

.hex-name-cn {
    font-family: var(--chinese);
    font-size: 3rem;
    font-weight: 700;
    color: var(--accent);
    margin: 0.25rem 0;
}

.hex-name-en {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-bright);
    font-style: italic;
    margin-bottom: 0.5rem;
}

.hex-trigrams {
    font-size: 0.9rem;
    color: var(--text-dim);
}

/* === Hexagram Figure (Lines) === */
.hexagram-figure {
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
    gap: 10px;
    padding: 1.5rem 0;
}

.hex-line {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    width: 180px;
    height: 14px;
    position: relative;
    animation: lineAppear 0.4s ease;
}

@keyframes lineAppear {
    from { opacity: 0; transform: scaleX(0.5); }
    to { opacity: 1; transform: scaleX(1); }
}

/* Yang line — solid */
.hex-line.yang .line-segment {
    flex: 1;
    height: 100%;
    background: var(--line-yang);
    border-radius: 2px;
}

/* Yin line — broken */
.hex-line.yin .line-segment {
    flex: 1;
    height: 100%;
    background: var(--line-yin);
    border-radius: 2px;
}

.hex-line.yin .line-gap {
    width: 20px;
    flex-shrink: 0;
}

/* Changing line glow */
.hex-line.changing .line-segment {
    background: var(--line-changing);
    box-shadow: 0 0 8px rgba(201, 168, 76, 0.4);
}

.hex-line .line-marker {
    position: absolute;
    right: -30px;
    font-size: 0.75rem;
    color: var(--line-changing);
}

/* === Reading === */
.reading {
    margin-bottom: 2.5rem;
}

.reading-section {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: var(--bg-card);
    border-left: 2px solid var(--border);
    border-radius: 0 4px 4px 0;
}

.reading-section h4 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    margin-bottom: 0.75rem;
}

.reading-section p {
    color: var(--text-bright);
    font-size: 1.05rem;
}

.changing-line-item {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.changing-line-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.changing-line-pos {
    font-size: 0.8rem;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    display: block;
    margin-bottom: 0.3rem;
}

.changing-line-text {
    color: var(--text-bright);
    font-style: italic;
}

/* === Question Echo === */
.question-echo {
    text-align: center;
    font-style: italic;
    color: var(--text-dim);
    font-size: 1rem;
    margin-bottom: 3rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border);
}

.question-echo:empty {
    display: none;
}

/* === Transformed Section === */
.transformed {
    margin-top: 3rem;
    padding-top: 3rem;
    border-top: 1px solid var(--border);
}

.transform-arrow {
    text-align: center;
    font-size: 2rem;
    color: var(--accent-dim);
    margin-bottom: 1rem;
}

.transform-title {
    text-align: center;
    font-size: 1rem;
    font-style: italic;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    margin-bottom: 2rem;
}

/* === Again Button === */
.again-button {
    display: block;
    margin: 3rem auto 0;
}

/* === Footer === */
footer {
    text-align: center;
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

footer p {
    font-size: 0.8rem;
    color: var(--text-dim);
    font-style: italic;
}

/* === Utilities === */
.hidden {
    display: none !important;
}

/* === Responsive === */
@media (max-width: 600px) {
    .container {
        padding: 2rem 1rem;
    }
    
    .title {
        font-size: 3rem;
    }
    
    .hex-name-cn {
        font-size: 2.2rem;
    }
    
    .hex-name-en {
        font-size: 1.2rem;
    }
    
    .hex-line {
        width: 140px;
    }
    
    .coins-container {
        gap: 1.5rem;
    }
    
    .coin {
        font-size: 2.5rem;
    }
}
