/* ═══════════════════════════════════════════════════
   ECHOES — GLOBAL STYLESHEET
   Shared across all pages.
   Upload to: css/global.css
   ═══════════════════════════════════════════════════ */

/* ── Variables ── */
:root {
    --parchment: #f4e4c1;
    --parchment-light: #faf3e3;
    --parchment-dark: #d4c4a3;
    --parchment-deep: #c4b493;
    --ink: #2c1810;
    --ink-light: #5a3a28;
    --ink-muted: #8a7060;
    --ink-faint: #b8a898;
    --gold: #c9a227;
    --gold-dark: #a67c00;
    --gold-light: #e8c84a;
    --crimson: #8b1a1a;
    --wood: #6b4423;
    --wood-light: #8b6243;
    --wood-dark: #4a2f15;
    --max-w: 860px;
    --font-display: 'Cinzel', 'Georgia', serif;
    --font-body: 'Lora', 'Georgia', serif;
}

.dark-mode {
    --parchment: #1a1410;
    --parchment-light: #251c14;
    --parchment-dark: #342820;
    --parchment-deep: #443830;
    --ink: #d4c4a8;
    --ink-light: #b8a888;
    --ink-muted: #887868;
    --ink-faint: #685848;
    --gold: #daa520;
    --gold-dark: #b8860b;
    --gold-light: #f0c040;
    --crimson: #cd3333;
    --wood: #3a2210;
    --wood-light: #4a3220;
    --wood-dark: #2a1808;
}

/* ── Reset & Base ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.75;
    background: var(--parchment);
    color: var(--ink);
    transition: background 0.4s, color 0.4s;
    overflow-x: hidden;
}

/* Parchment grain */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 9999;
}

h1, h2, h3, h4 { font-family: var(--font-display); color: var(--ink); line-height: 1.3; }
h1 { font-size: clamp(2rem, 5vw, 3.5rem); }
h2 { font-size: clamp(1.4rem, 3vw, 2rem); }
h3 { font-size: clamp(1.1rem, 2vw, 1.4rem); }
p { margin-bottom: 1rem; color: var(--ink-light); }
a { color: var(--gold-dark); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--gold); }
img { max-width: 100%; }
small { font-size: 0.85rem; color: var(--ink-muted); }

/* ── Scroll Roll Top ── */
.scroll-roll-top {
    height: 32px;
    background: linear-gradient(to bottom,
        var(--wood-dark) 0%, var(--wood-light) 15%,
        var(--wood) 45%, var(--wood-dark) 85%, var(--wood-light) 100%);
    box-shadow: 0 6px 16px rgba(0,0,0,0.25), inset 0 2px 3px rgba(255,255,255,0.08);
    position: relative;
    z-index: 100;
}
.scroll-roll-top::before, .scroll-roll-top::after {
    content: '';
    position: absolute;
    top: 2px;
    width: 40px;
    height: 28px;
    background: linear-gradient(to bottom, var(--wood-light), var(--wood), var(--wood-dark));
    border-radius: 14px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}
.scroll-roll-top::before { left: -8px; }
.scroll-roll-top::after { right: -8px; }

.scroll-curl {
    height: 20px;
    background: linear-gradient(to bottom, var(--parchment-dark), var(--parchment));
    border-radius: 0 0 50% 50% / 0 0 100% 100%;
    margin-top: -2px;
}

/* ── Scroll Card ── */
.scroll-card {
    background: linear-gradient(145deg, var(--parchment-light) 0%, var(--parchment) 100%);
    border: 1px solid var(--parchment-deep);
    border-radius: 3px;
    padding: 2.5rem 2rem;
    position: relative;
    margin-bottom: 2rem;
    box-shadow:
        inset 0 0 50px rgba(139,106,78,0.06),
        0 2px 8px rgba(0,0,0,0.05),
        0 8px 24px rgba(0,0,0,0.03);
}
.scroll-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 3px;
    background:
        linear-gradient(to right, rgba(139,106,78,0.1) 0%, transparent 4%, transparent 96%, rgba(139,106,78,0.1) 100%),
        linear-gradient(to bottom, rgba(139,106,78,0.06) 0%, transparent 6%, transparent 94%, rgba(139,106,78,0.06) 100%);
    pointer-events: none;
}

/* ── Wax Seal ── */
.wax-seal {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    background: radial-gradient(circle at 35% 35%, #d44040, #8b1a1a, #5a0f0f);
    border-radius: 50%;
    box-shadow: 0 3px 10px rgba(0,0,0,0.3), inset 0 1px 3px rgba(255,255,255,0.15);
    font-size: 1.6rem;
    margin-bottom: 1rem;
    transition: transform 0.3s;
}
.wax-seal:hover { transform: scale(1.08) rotate(-5deg); }

/* ── Layout ── */
.container { max-width: var(--max-w); margin: 0 auto; padding: 0 1.5rem; }
section { padding: 4rem 0; }
.main-content { padding-top: 1rem; }

/* ── Navigation ── */
.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--parchment);
    border-bottom: 1px solid var(--parchment-deep);
    padding: 0.8rem 0;
    transition: background 0.4s;
}
.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}
.logo {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--ink);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.logo-icon { font-size: 1.6rem; }
.nav-links {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    flex-wrap: wrap;
}
.nav-links a {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--ink-muted);
    transition: color 0.2s;
}
.nav-links a:hover { color: var(--gold); }
.nav-current {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--gold-dark);
}
.hamburger {
    display: none;
    background: none;
    border: none;
    font-size: 1.6rem;
    cursor: pointer;
    color: var(--ink);
}
.theme-toggle {
    background: none;
    border: 1px solid var(--parchment-deep);
    border-radius: 50%;
    width: 38px;
    height: 38px;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ink);
    transition: border-color 0.2s;
}
.theme-toggle:hover { border-color: var(--gold); }

/* ── Buttons ── */
.btn {
    display: inline-block;
    padding: 0.75rem 1.8rem;
    border-radius: 4px;
    font-family: var(--font-display);
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: all 0.25s;
    text-align: center;
}
.btn-gold {
    background: linear-gradient(135deg, var(--gold-light), var(--gold), var(--gold-dark));
    color: #fff;
    box-shadow: 0 2px 8px rgba(201,162,39,0.3);
}
.btn-gold:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(201,162,39,0.4);
    color: #fff;
}
.btn-outline {
    background: transparent;
    border: 2px solid var(--gold);
    color: var(--gold-dark);
}
.btn-outline:hover {
    background: var(--gold);
    color: #fff;
}

/* ── Section Headers ── */
.section-header {
    text-align: center;
    margin-bottom: 2.5rem;
}
.section-header .eyebrow {
    font-size: 0.75rem;
    color: var(--gold);
    text-transform: uppercase;
    letter-spacing: 0.2em;
    font-family: var(--font-display);
    display: block;
    margin-bottom: 0.5rem;
}
.section-header h2 { margin-bottom: 0.5rem; }
.section-header p { color: var(--ink-muted); max-width: 520px; margin: 0 auto; }

/* ── Dividers ── */
.divider {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin: 2rem 0;
    color: var(--ink-faint);
}
.divider::before, .divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(to right, transparent, var(--parchment-deep), transparent);
}

/* ── Chapter Header (tool pages) ── */
.chapter-header {
    text-align: center;
    padding: 3rem 0 1rem;
}
.chapter-header .chapter-num {
    font-size: 0.75rem;
    color: var(--gold);
    text-transform: uppercase;
    letter-spacing: 0.25em;
    font-family: var(--font-display);
    display: block;
    margin-bottom: 0.5rem;
}
.chapter-header h1 { margin-bottom: 0.8rem; }
.chapter-header .chapter-poem {
    font-style: italic;
    color: var(--ink-muted);
    max-width: 480px;
    margin: 0 auto;
    line-height: 1.8;
}
.chapter-header .chapter-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 1rem;
}

/* ── Form Elements ── */
.form-group { margin-bottom: 1.2rem; }
.form-group label {
    display: block;
    font-family: var(--font-display);
    font-size: 0.85rem;
    color: var(--ink-muted);
    margin-bottom: 0.3rem;
    letter-spacing: 0.03em;
}
.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.8rem 1rem;
    background: var(--parchment);
    border: 1px solid var(--parchment-deep);
    border-radius: 4px;
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 1rem;
    transition: border-color 0.2s;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--gold);
}
.form-group textarea { border-radius: 8px; resize: vertical; min-height: 100px; }
.form-group select {
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238a7060' d='M3 4.5L6 8l3-3.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}
.form-row { display: flex; gap: 1rem; }
.form-row > * { flex: 1; }
.form-actions { display: flex; gap: 0.8rem; flex-wrap: wrap; margin-top: 1rem; }

/* ── Steps ── */
.steps { display: grid; gap: 1.5rem; margin-top: 1.5rem; }
.step { display: flex; gap: 1.2rem; align-items: flex-start; }
.step-num {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--gold-light), var(--gold-dark));
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1rem;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
.step-content h4 { font-size: 1rem; margin-bottom: 0.2rem; }
.step-content p { font-size: 0.9rem; color: var(--ink-muted); margin: 0; }

/* ── Tool Cards Grid ── */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.2rem;
    margin-top: 1.5rem;
}
.tool-card {
    background: var(--parchment-light);
    border: 1px solid var(--parchment-deep);
    border-radius: 6px;
    padding: 1.5rem;
    text-align: center;
    transition: all 0.25s;
    text-decoration: none;
    display: block;
    opacity: 0;
    transform: translateY(20px);
}
.tool-card.visible {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.5s ease, transform 0.5s ease;
}
.tool-card:hover {
    border-color: var(--gold);
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.08);
}
.tool-card .icon { font-size: 2rem; margin-bottom: 0.6rem; display: block; }
.tool-card h3 { font-size: 1rem; margin-bottom: 0.3rem; color: var(--ink); }
.tool-card p { font-size: 0.8rem; color: var(--ink-muted); margin: 0; }

/* ── Support Cards ── */
.support-cards {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 1.5rem;
}
.support-card {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.8rem 1.5rem;
    background: var(--parchment-light);
    border: 1px solid var(--parchment-deep);
    border-radius: 6px;
    text-decoration: none;
    color: var(--ink);
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s;
}
.support-card:hover {
    border-color: var(--gold);
    transform: translateY(-2px);
    color: var(--gold-dark);
}

/* ── Status Messages ── */
.status-box {
    padding: 1rem 1.2rem;
    border-radius: 6px;
    font-size: 0.9rem;
    margin: 1rem 0;
}
.status-box.info {
    background: rgba(201,162,39,0.08);
    border: 1px solid rgba(201,162,39,0.2);
    color: var(--ink-light);
}
.status-box.success {
    background: rgba(74,103,65,0.08);
    border: 1px solid rgba(74,103,65,0.2);
    color: var(--ink-light);
}
.status-box.warning {
    background: rgba(139,26,26,0.08);
    border: 1px solid rgba(139,26,26,0.2);
    color: var(--ink-light);
}

/* ── Footer ── */
.site-footer {
    background: var(--ink);
    color: var(--parchment-deep);
    padding: 3rem 0 2rem;
    text-align: center;
}
.site-footer h4 { color: var(--gold); margin-bottom: 1rem; font-size: 1rem; }
.footer-links {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}
.footer-links a {
    color: var(--parchment-dark);
    font-size: 0.85rem;
    transition: color 0.2s;
}
.footer-links a:hover { color: var(--gold); }
.footer-bottom {
    font-size: 0.8rem;
    color: var(--ink-muted);
    margin-top: 1rem;
    border-top: 1px solid var(--wood-dark);
    padding-top: 1rem;
}
.footer-memorial {
    font-style: italic;
    color: var(--ink-faint);
    margin-top: 0.5rem;
    font-size: 0.85rem;
}

/* ── Chatbot ── */
.chat-fab {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 200;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.7rem 1.2rem;
    background: linear-gradient(135deg, var(--gold-light), var(--gold-dark));
    color: #fff;
    border: none;
    border-radius: 40px;
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(201,162,39,0.4);
    transition: transform 0.2s, box-shadow 0.2s;
    animation: gentlePulse 3s ease-in-out infinite;
}
.chat-fab:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(201,162,39,0.5);
}
.chat-fab .fab-icon { font-size: 1.3rem; }

@keyframes gentlePulse {
    0%, 100% { box-shadow: 0 4px 16px rgba(201,162,39,0.4); }
    50% { box-shadow: 0 4px 24px rgba(201,162,39,0.6); }
}

.chat-panel {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 360px;
    max-height: 480px;
    z-index: 201;
    display: none;
    flex-direction: column;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 12px 40px rgba(0,0,0,0.25);
    border: 2px solid var(--wood);
}
.chat-panel.open { display: flex; }

.chat-scroll-header {
    background: linear-gradient(to bottom, var(--wood-dark), var(--wood));
    color: var(--parchment-light);
    padding: 0.8rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.chat-scroll-header .char-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.chat-scroll-header .char-icon {
    font-size: 1.5rem;
    background: var(--parchment);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.chat-scroll-header .char-name {
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-weight: 600;
}
.chat-scroll-header .char-role { font-size: 0.7rem; opacity: 0.7; }
.chat-close {
    background: none;
    border: none;
    color: var(--parchment-dark);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.2rem;
    line-height: 1;
    transition: color 0.2s;
}
.chat-close:hover { color: var(--gold); }

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    background: var(--parchment-light);
    min-height: 200px;
}
.chat-msg {
    margin-bottom: 0.8rem;
    padding: 0.6rem 0.9rem;
    border-radius: 10px;
    font-size: 0.9rem;
    line-height: 1.5;
    max-width: 85%;
}
.chat-msg.bot {
    background: var(--parchment);
    border: 1px solid var(--parchment-deep);
    color: var(--ink-light);
}
.chat-msg.user {
    background: linear-gradient(135deg, var(--gold-light), var(--gold));
    color: #fff;
    margin-left: auto;
    border-bottom-right-radius: 3px;
}
.chat-msg a { color: var(--gold-dark); text-decoration: underline; }
.chat-msg.user a { color: #fff; }

.chat-input-row {
    display: flex;
    background: var(--parchment);
    border-top: 1px solid var(--parchment-deep);
}
.chat-input-row input {
    flex: 1;
    padding: 0.8rem;
    border: none;
    background: transparent;
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 0.9rem;
    outline: none;
}
.chat-input-row button {
    background: var(--gold);
    border: none;
    color: #fff;
    padding: 0 1rem;
    cursor: pointer;
    font-size: 1.1rem;
    transition: background 0.2s;
}
.chat-input-row button:hover { background: var(--gold-dark); }

/* ── Cookie Consent ── */
.cookie-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 300;
    background: var(--ink);
    color: var(--parchment-dark);
    padding: 1rem 1.5rem;
    display: none;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
    font-size: 0.85rem;
    box-shadow: 0 -4px 16px rgba(0,0,0,0.2);
}
.cookie-bar.visible { display: flex; }
.cookie-bar a { color: var(--gold); text-decoration: underline; }
.cookie-bar .btn { padding: 0.5rem 1.2rem; font-size: 0.8rem; }

/* ── Privacy Modal ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 400;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.modal-overlay.open { display: flex; }
.modal-box {
    background: var(--parchment-light);
    border: 2px solid var(--wood);
    border-radius: 8px;
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    padding: 2rem;
    position: relative;
}
.modal-box h2 { margin-bottom: 1rem; }
.modal-box h3 { margin: 1.2rem 0 0.4rem; font-size: 1rem; }
.modal-box p, .modal-box li { font-size: 0.9rem; color: var(--ink-light); }
.modal-box ul { padding-left: 1.5rem; margin: 0.5rem 0; }
.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--ink-muted);
}

/* ── Particles ── */
.particles {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    overflow: hidden;
}
.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--gold);
    border-radius: 50%;
    opacity: 0;
    animation: floatUp linear infinite;
}
@keyframes floatUp {
    0% { opacity: 0; transform: translateY(100vh) scale(0); }
    10% { opacity: 0.6; }
    90% { opacity: 0.6; }
    100% { opacity: 0; transform: translateY(-10vh) scale(1); }
}

/* ── Fade-in on scroll ── */
.fade-in {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}
.fade-in.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .hamburger { display: block; }
    .nav-links {
        display: none;
        flex-direction: column;
        width: 100%;
        padding: 1rem 0;
        border-top: 1px solid var(--parchment-deep);
        margin-top: 0.5rem;
    }
    .nav-links.show { display: flex; }
    section { padding: 2.5rem 0; }
    .scroll-card { padding: 1.5rem 1.2rem; }
    .form-row { flex-direction: column; gap: 0; }
    .tools-grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
}

@media (max-width: 480px) {
    .chat-panel {
        inset: 10px;
        width: auto;
        max-height: none;
        bottom: 10px;
        right: 10px;
        border-radius: 12px;
    }
    .chat-fab {
        bottom: 16px;
        right: 16px;
        padding: 0.6rem 1rem;
        font-size: 0.8rem;
    }
    .chat-fab .fab-text { display: none; }
}
