@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;500;600&family=Crimson+Text:ital,wght@0,400;0,600;1,400&display=swap');

/* Reset and base styles */
* { box-sizing: border-box; }

body {
    font-family: 'Crimson Text', 'Times New Roman', serif;
    font-weight: 400;
    background: linear-gradient(135deg, #1a0d0a 0%, #2d1b15 25%, #1e1a0d 50%, #0f0a0f 75%, #1a0a1a 100%);
    background-attachment: fixed;
    color: #d4c4a8;
    min-height: 100vh;
    margin: 0;
    padding: 0;
    position: relative;
    overflow-x: hidden;
    animation: candleFlicker 4s ease-in-out infinite;
}

/* Victorian damask pattern overlay */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(circle at 50px 50px, rgba(139, 69, 19, 0.08) 2px, transparent 2px),
        radial-gradient(circle at 100px 100px, rgba(85, 107, 47, 0.06) 1px, transparent 1px),
        linear-gradient(45deg, rgba(72, 61, 139, 0.03) 25%, transparent 25%),
        linear-gradient(-45deg, rgba(75, 0, 130, 0.04) 25%, transparent 25%);
    background-size: 100px 100px, 50px 50px, 200px 200px, 180px 180px;
    animation: victorialFloat 30s ease-in-out infinite;
    pointer-events: none;
    z-index: -1;
}

/* Animations */
@keyframes victorialFloat {
    0%, 100% { transform: translateY(0px) rotate(0deg); opacity: 0.7; }
    25% { transform: translateY(-5px) rotate(0.5deg); opacity: 0.8; }
    50% { transform: translateY(0px) rotate(-0.3deg); opacity: 0.6; }
    75% { transform: translateY(3px) rotate(0.2deg); opacity: 0.9; }
}

@keyframes candleFlicker {
    0%, 100% { filter: brightness(1.1) hue-rotate(0deg); }
    25% { filter: brightness(1.12) hue-rotate(1deg); }
    50% { filter: brightness(0.99) hue-rotate(-1deg); }
    75% { filter: brightness(1.08) hue-rotate(0.5deg); }
}

@keyframes textAppear {
    0% { opacity: 0; transform: translateY(20px); }
    100% { opacity: 1; transform: translateY(0); }
}

@keyframes choiceAppear {
    0% { opacity: 0; transform: translateY(15px); }
    100% { opacity: 1; transform: translateY(0); }
}

@keyframes linkAppear {
    0% { opacity: 0; transform: translateY(10px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* Layout containers */
.outerContainer {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    position: relative;
}

#controls {
    width: 80%;
    margin: 1rem auto;
    display: flex;
    flex-direction: row;
    justify-content: space-evenly;
}

/* Story container */
.container {
    display: block;
    max-width: 700px;
    margin: 0 auto;
    padding: 50px 40px;
    position: relative;
    background: linear-gradient(135deg, rgba(45, 27, 21, 0.85) 0%, rgba(30, 26, 13, 0.9) 50%, rgba(26, 10, 26, 0.85) 100%);
    border: 3px solid;
    border-image: linear-gradient(45deg, #8b4513, #daa520, #cd853f, #8b4513) 1;
    box-shadow: 
        0 0 30px rgba(0, 0, 0, 0.8),
        inset 0 1px 0 rgba(218, 165, 32, 0.2),
        inset 0 -1px 0 rgba(139, 69, 19, 0.3);
    transition: height 0.6s ease;
}

/* Victorian corner ornaments */
.container::before, .container::after {
    content: '';
    position: absolute;
    width: 30px;
    height: 30px;
    border: 2px solid #daa520;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(218, 165, 32, 0.3), transparent);
}

.container::before {
    top: -15px;
    left: -15px;
    border-bottom: none;
    border-right: none;
}

.container::after {
    bottom: -15px;
    right: -15px;
    border-top: none;
    border-left: none;
}

.container:hover {
    background: linear-gradient(135deg, rgba(45, 27, 21, 0.9) 0%, rgba(30, 26, 13, 0.95) 50%, rgba(26, 10, 26, 0.9) 100%);
    box-shadow: 
        0 0 40px rgba(0, 0, 0, 0.9),
        0 0 80px rgba(218, 165, 32, 0.1),
        inset 0 1px 0 rgba(218, 165, 32, 0.3),
        inset 0 -1px 0 rgba(139, 69, 19, 0.4);
}

/* Header section */
.header {
    text-align: center;
    margin-bottom: 40px;
    border-bottom: 2px solid rgba(139, 69, 19, 0.3);
    padding-bottom: 30px;
}

/* Typography */
h1 {
    font-family: 'Cinzel', serif;
    font-weight: 600;
    font-size: 3.2rem;
    color: #f4e4bc;
    text-shadow: 
        2px 2px 0px #8b4513,
        4px 4px 8px rgba(0, 0, 0, 0.8),
        0 0 15px rgba(218, 165, 32, 0.3),
        0 0 25px rgba(218, 165, 32, 0.2);
    letter-spacing: 3px;
    margin: 0 0 1rem 0;
    position: relative;
    text-transform: uppercase;
}

h1::before, h1::after {
    content: '❦';
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.5rem;
    color: #daa520;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.6);
}

h1::before { left: -60px; }
h1::after { right: -60px; }

.byline {
    font-family: 'Crimson Text', serif;
    font-size: 1.2rem;
    font-style: italic;
    color: #cd853f;
    margin: 0;
    font-weight: 400;
    opacity: 0.8;
}

/* Story content */
p {
    color: #d4c4a8;
    line-height: 1.9em;
    font-size: 15pt;
    font-weight: 400;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.7);
    font-style: normal;
    margin: 1.5em 0;
    opacity: 0;
    transform: translateY(20px);
    animation: textAppear 0.8s ease forwards;
}

p:nth-child(1) { animation-delay: 0.2s; }
p:nth-child(2) { animation-delay: 0.4s; }
p:nth-child(3) { animation-delay: 0.6s; }
p:nth-child(4) { animation-delay: 0.8s; }
p:nth-child(5) { animation-delay: 1.0s; }
p:nth-child(6) { animation-delay: 1.2s; }

p.choice {
    text-align: center;
    padding: 1rem 0;
    font-style: italic;
    margin: 0;
    animation: choiceAppear 0.7s ease forwards;
    animation-delay: 1.4s;
}

/* Drop cap */
p:not(.choice):first-of-type:first-letter {
    font-family: 'Cinzel', serif;
    font-size: 4rem;
    font-weight: 600;
    float: left;
    line-height: 3.5rem;
    padding-right: 8px;
    padding-top: 4px;
    color: #daa520;
    text-shadow: 
        2px 2px 4px rgba(0, 0, 0, 0.8),
        0 0 10px rgba(218, 165, 32, 0.3);
}

/* Fixed branding and button links */
.written-in-ink, .buttons {
    text-align: center;
    font-size: 0.9rem;
    opacity: 0.7;
}

.written-in-ink > a, .buttons > a {
    color: #b36d3b;
    text-decoration: none;
    font-weight: 500;
    letter-spacing: 1px;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    outline: none;
    position: relative;
}

.written-in-ink > a::before, .buttons > a::before {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 0;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, #8b4513, #daa520, #cd853f);
    transition: width 0.4s ease;
    box-shadow: 0 0 5px rgba(218, 165, 32, 0.5);
}

.written-in-ink > a:hover, .buttons > a:hover {
    color: #cd853f;
    text-shadow: 0 0 5px currentColor, 2px 2px 4px rgba(0, 0, 0, 0.8);
    transform: translateY(-2px);
    letter-spacing: 1.5px;
}

.written-in-ink > a:hover::before, .buttons > a:hover::before {
    width: 100%;
}

/* Story choice links */
a:not(.buttons > a):not(.written-in-ink > a) {
    color: #cd853f;
    text-decoration: none;
    position: relative;
    transition: all 0.3s ease;
    border-bottom: 1px solid transparent;
    font-weight: 600;
    cursor: pointer;
    opacity: 0;
    animation: linkAppear 0.6s ease forwards;
    animation-delay: 1.6s;
}

/* Victorian ornate link underline */
a:not(.buttons > a):not(.written-in-ink > a)::before {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 0;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, #8b4513, #daa520, #cd853f);
    transition: width 0.4s ease;
    box-shadow: 0 0 5px rgba(218, 165, 32, 0.5);
}

a:not(.buttons > a):not(.written-in-ink > a)::after {
    content: '⚜';
    position: absolute;
    right: -20px;
    top: 50%;
    transform: translateY(-50%) scale(0);
    color: #daa520;
    font-size: 0.8rem;
    transition: transform 0.3s ease;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

a:not(.buttons > a):not(.written-in-ink > a):hover {
    color: #f4e4bc;
    text-shadow: 
        0 0 5px currentColor,
        2px 2px 4px rgba(0, 0, 0, 0.8);
    transform: translateY(-2px);
    letter-spacing: 1px;
}

a:not(.buttons > a):not(.written-in-ink > a):hover::before {
    width: 100%;
}

a:not(.buttons > a):not(.written-in-ink > a):hover::after {
    transform: translateY(-50%) scale(1);
}

/* Victorian scrollbar */
::-webkit-scrollbar { width: 12px; }
::-webkit-scrollbar-track {
    background: linear-gradient(180deg, #1a0d0a, #2d1b15);
    border-left: 1px solid #8b4513;
}
::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #8b4513, #cd853f, #daa520);
    border-radius: 6px;
    border: 1px solid #654321;
}
::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #daa520, #cd853f, #8b4513);
}

/* Responsive design */
@media screen and (max-width: 768px) {
    .outerContainer { padding: 10px; }
    .container { padding: 30px 20px; margin: 0 10px; transition: height 0.3s ease; }
    h1 { font-size: 2.5rem; letter-spacing: 2px; }
    h1::before, h1::after { display: none; }
    p { font-size: 14pt; line-height: 1.7em; animation-duration: 0.5s; }
    p:not(.choice):first-of-type:first-letter { font-size: 3rem; line-height: 2.5rem; }
    .buttons { gap: 10px; }
    .buttons a { padding: 6px 12px; font-size: 0.8rem; }
}

@media screen and (max-width: 480px) {
    h1 { font-size: 2rem; letter-spacing: 1px; }
    .container { padding: 20px 15px; transition: height 0.25s ease; }
    p { font-size: 13pt; animation-duration: 0.4s; }
    .buttons { flex-direction: column; align-items: center; }
    .buttons a { width: 120px; text-align: center; }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    p { opacity: 1; transform: none; }
    a { opacity: 1; }
}
