/* style.css */
:root {
    --ink-color: #111a22; /* Very dark, old ink */
    --paper-color: #dcd3c1;
}

body, html {
    margin: 0;
    padding: 0;
    height: 100%;
    background-color: var(--paper-color);
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: 'Caveat', cursive;
    overflow: hidden;
}

/* The full-screen parchment page */
.diary-container {
    width: 100vw;
    height: 100vh;
    background-color: var(--paper-color);
    background-image: 
        url('https://www.transparenttextures.com/patterns/old-wall.png'),
        radial-gradient(ellipse at center, rgba(255,255,255,0.1) 0%, rgba(0,0,0,0.5) 120%);
    background-blend-mode: overlay, normal;
    box-shadow: inset 0 0 150px rgba(0,0,0,0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

/* Candlelight flickering effect on the whole page */
.diary-container::after {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: radial-gradient(circle at 50% 50%, rgba(255, 140, 0, 0.04) 0%, rgba(0, 0, 0, 0.4) 100%);
    pointer-events: none;
    animation: flicker 4s infinite alternate;
    z-index: 100;
}

@keyframes flicker {
    0% { opacity: 0.9; }
    10% { opacity: 0.85; }
    20% { opacity: 0.95; }
    30% { opacity: 0.8; }
    40% { opacity: 0.9; }
    50% { opacity: 0.85; }
    60% { opacity: 1; }
    70% { opacity: 0.9; }
    80% { opacity: 0.8; }
    90% { opacity: 0.95; }
    100% { opacity: 0.85; }
}

/* Film grain */
.diary-container::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image: url('https://www.transparenttextures.com/patterns/stardust.png');
    opacity: 0.3;
    pointer-events: none;
    z-index: 5;
}

.page {
    width: 100%;
    max-width: 900px; /* Keep text readable in middle */
    height: 100%;
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 0 40px;
    box-sizing: border-box;
}

#conversation-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center; 
    padding-bottom: 20px;
    overflow: hidden;
    z-index: 20;
}

.message {
    font-size: 3.5rem;
    color: var(--ink-color);
    margin-bottom: 20px;
    opacity: 0;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
    line-height: 1.2;
    animation: ink-settle 1.5s forwards;
}

@keyframes ink-settle {
    0% { filter: blur(3px); }
    100% { filter: blur(0.5px); }
}

.message.user {
    text-align: center;
}

.message.riddle {
    text-align: center;
    color: #0b1016; 
}

/* For letter by letter fade in */
.letter {
    opacity: 0;
    display: inline-block; 
    filter: blur(3px);
    transition: opacity 1s ease-in, filter 1.5s ease-out;
}

.input-container {
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
    margin-bottom: 30px;
}

#user-input {
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    font-family: 'Caveat', cursive;
    font-size: 3.5rem;
    color: var(--ink-color);
    text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
    padding: 0;
    caret-color: var(--ink-color);
    text-align: center;
    filter: blur(0.5px);
}

#user-input::placeholder {
    color: rgba(17, 26, 34, 0.2);
}

#user-input:disabled {
    opacity: 0;
    transition: opacity 0.5s ease;
}

.fade-in {
    opacity: 1 !important;
    filter: blur(0.5px) !important;
}

.fade-out {
    opacity: 0 !important;
    filter: blur(3px) !important;
    transition: opacity 2s ease, filter 2s ease;
}

/* Random Ink Spill Effect */
.ink-spill {
    position: absolute;
    background: var(--ink-color);
    border-radius: 40% 60% 70% 30% / 40% 50% 60% 50%;
    filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    transform: scale(0.1);
    animation: spill 4s ease-out forwards;
    z-index: 10;
}

@keyframes spill {
    0% { transform: scale(0.1); opacity: 0; filter: blur(1px); }
    10% { opacity: 0.8; filter: blur(1.5px); }
    50% { transform: scale(1); opacity: 0.6; filter: blur(2px); }
    100% { opacity: 0; transform: scale(1.1); filter: blur(6px); }
}
