@import url('https://fonts.googleapis.com/css2?family=EB+Garamond:ital,wght@0,400;0,600;1,400&family=IM+Fell+English+SC&family=Libre+Baskerville:wght@400;700&display=swap');

@import url('https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@7.2.0/css/all.min.css');

:root {
	/* Base Colors - The "Scriptorium" Palette */
    --bg-body: #1C1917;        /* Obsidian Ink: Deep, warm black */
    --bg-surface: #F2EADC;     /* Aged Vellum: Rich, historic cream */
    --text-primary: #2D2824;   /* Walnut Husk: Soft dark brown for legibility */
    --text-secondary: #5C524A; /* Tanned Leather: Mid-tone for subtext */
    --text-muted: #63584F;     /* Dried Papyrus: Darkened for 65+ contrast (was #73675C) */
    --text-ink: #3D3630;       /* Iron Gall: Deepest brown for accents */

    /* Accent Colors - Organic & Earthy */
    --accent-brass: #92400E;   /* Oxidized Gold: Muted metallic */
    --accent-brass-glow: rgba(146, 64, 14, 0.1); 
    --accent-copper: #78350F;  /* Burnt Sienna: Deep wax seal orange-brown */
    --accent-warning: #914C3E; /* Oxide Red: For caution */
    --border-elegant: #D6C6AD; /* Dusty Linen: Blends with the vellum */

	/* The "Scholar's Edition" Typography */
    --font-header: "IM Fell English SC", serif; /* Monumental & Inky */
    --font-body: "EB Garamond", serif;          /* Academic & Fluid */
    --font-nav: "Libre Baskerville", serif;     /* Functional & Sturdy */
    --max-width: 880px;
}

html {
    scroll-behavior: smooth;
	scroll-padding-top: 2rem;
}

* {
    box-sizing: border-box;
}

body {
    background-color: var(--bg-body);
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.05'/%3E%3C/svg%3E");
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 1.55rem; 
    line-height: 1.75; 
    margin: 0;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#pap {
    width: 100%;
    max-width: var(--max-width);
    margin: 0 auto;
    background: var(--bg-surface);
    padding: 3.5rem 2.5rem;
    min-height: 100vh;
	box-shadow: 0 0 60px rgba(28, 25, 23, 0.6); /* Shadow tinted with Obsidian Ink */
    border-left: 1px solid var(--border-elegant);
    border-right: 1px solid var(--border-elegant);
}

/* ==========================================================================
   BUTTONS & ACCESSIBILITY 
   ========================================================================== */
#expand-all, #collapse-all, .nav-btn, .action-tool-link, .action-btn, .reflect-btn {
    background: transparent; 
    color: var(--accent-copper);
    border: 1px solid var(--accent-copper); 
    padding: 8px 16px; 
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 4px; 
    font-family: var(--font-nav);
    font-weight: 600;
    font-size: 0.9rem; 
    cursor: pointer;
    text-decoration: none;
    transition: all 0.25s ease-in-out;
    letter-spacing: 0.05em;
}

@media (hover: hover) {
    #expand-all:hover, #collapse-all:hover, .nav-btn:hover, .action-tool-link:hover, .action-btn:hover, .reflect-btn:hover {
        background: var(--accent-brass-glow); 
        transform: translateY(-1px); 
    }
}

:focus-visible {
    outline: 2px solid var(--accent-copper);
    outline-offset: 3px;
}

/* ==========================================================================
   TYPOGRAPHY, BREADCRUMBS & HEADER PLATES
   ========================================================================== */
.sc { 
    font-variant: small-caps; 
    letter-spacing: 0.05em;
    color: var(--text-ink); 
}

.archival-plate {
    text-align: center;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 3px double var(--accent-brass); 
}

.arrival-note {
	font-size: 1.35rem;
	line-height: 1.55;
	text-align: left;
}

.logo-text {
    display: block;
    font-family: var(--font-header);
    font-size: 2.9rem;
    font-weight: 600;
	letter-spacing: .06rem;
    color: var(--accent-brass);
}

.motto {
    font-family: var(--font-header);
    font-size: 1.5rem;
    letter-spacing: 0.15em;
    color: var(--accent-brass);
    font-weight: 600;
    display: block;
    margin-top: 0.5rem;
}

.content-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.breadcrumbs {
    font-family: var(--font-nav);
    font-size: 0.95rem;
    color: var(--accent-copper);
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.breadcrumbs a {
    color: var(--accent-brass);
    text-decoration: none;
    transition: color 0.3s ease;
}

@media (hover: hover) {
    .breadcrumbs a:hover {
        color: var(--accent-copper);
    }
}

h1.sourceTitle {
    font-family: var(--font-body);
    font-size: 1.55rem; 
    color: var(--accent-copper);
    letter-spacing: 0.07em;
    margin: 0; 
    line-height: 1.4;
	-webkit-font-smoothing: subpixel-antialiased;
    -moz-osx-font-smoothing: auto;
}

.trail-markers {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.8rem;
    color: var(--accent-brass); 
    margin: 1.5rem 0;
 }

.trail-markers i:nth-child(1) { font-size: 0.3rem; opacity: 0.4; }
.trail-markers i:nth-child(2) { font-size: 0.4rem; opacity: 0.7; }
.trail-markers i:nth-child(3) { font-size: 0.5rem; opacity: 1; }

/* ==========================================================================
   ICONOGRAPHY COLORS
   ========================================================================== */
summary .fa-solid.icon-brass {
    color: var(--accent-brass); /* Oxidized Gold for top-level mechanics */
}

summary .fa-solid.icon-copper {
    color: var(--accent-copper); /* Burnt Sienna for secondary emphasis */
}

summary .fa-solid.icon-iron {
    color: var(--text-ink); /* Iron Gall for sub-level structural gears */
}

/* ==========================================================================
   READING CONTENT (Paragraphs)
   ========================================================================== */
main p {
    margin-bottom: 2.0rem;
	margin-left: 2.5rem;
    margin-right: 2.5rem;
    font-size: 1.45rem;
    text-align: left;
    color: var(--text-primary);
}

main blockquote {
    margin-bottom: 2.0rem;
	margin-left: 2.5rem;
    margin-right: 2.5rem;
    font-size: 1.45rem;
	font-style: italic;
    text-align: left;
    color: var(--text-primary);
}

/* ==========================================================================
   PROGRESS TRACKER & MAP ROOM (Index)
   ========================================================================== */
#stats-container {
    background: transparent;
    padding: 1.5rem 0;
    border-top: 1px solid var(--border-elegant);
    border-bottom: 1px solid var(--border-elegant);
    margin-bottom: 2rem;
    display: block;
}

.stats-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    font-family: var(--font-header);
    font-weight: 700;
    color: var(--text-secondary);
    font-size: 1.0rem;
    letter-spacing: 0.05em;
}

#stats-pct, .stat-number {
    font-size: 1.0rem;
	font-family: var(--font-nav);
	color: var(--accent-copper);
}

.stats-data {
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
}

.progress-bar-bg {
    background: var(--accent-brass-glow);
    height: 12px; 
    border-radius: 6px;
    border: 1px solid var(--border-elegant);
    overflow: hidden;
}

#stats-fill {
    background: var(--accent-brass); 
    height: 100%;
    transition: width 1s ease-in-out;
}

.tree ul {
    list-style: none;
    padding-left: 1.2rem;
    margin: 0.5rem 0;
    border-left: 1px solid var(--border-elegant); 
}

.tree li { margin: 0.5rem 0; }

.tree summary {
    cursor: pointer;
    font-family: var(--font-header);
    font-weight: 600;
    padding: 1rem;
    background: var(--accent-brass-glow);
    border-radius: 4px;
    list-style: none;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
}

.tree summary:focus-visible {
    outline: 2px solid var(--accent-copper);
    outline-offset: 2px;
}

summary .fa-solid {
	color: var(--accent-brass);
}

.tree-controls {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin: 1.5rem 0;
}

.tree a {
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 600;
    border-bottom: 1px solid var(--border-elegant);
    display: inline-block;
    padding: 8px 0; 
}

.tree a.trail-completed {
    color: var(--text-muted);
    text-decoration: line-through;
    opacity: 0.5;
}

.tree a.trail-completed::after {
    content: " \2713";
    font-weight: bold;
    margin-left: 8px;
    color: var(--accent-brass);
}

/* ==========================================================================
   REFLECTION SECTION (Added Divider)
   ========================================================================== */
.reflection-section { 
    text-align: center; 
    margin-top: 2rem;
    padding-top: 1.5rem;
    margin-bottom: 1.5rem;
    margin-left: 2.5rem; 
    margin-right: 2.5rem;
    border-top: 3px double var(--accent-copper); 
}

.reflection-box {
    display: none; 
    width: 100%;
    min-height: 200px;
    font-size: 1.3rem;
    padding: 15px;
    background: #FAF7F0;
    border: 1px solid var(--border-elegant);
    border-top: 3px solid var(--accent-brass); 
	box-shadow: inset 0 2px 10px rgba(45, 40, 36, 0.08);
    margin-top: 15px;
    font-family: var(--font-body);
}

.print-reflection-output {
    display: none;
    font-size: 1.3rem;
    text-align: left;
    padding: 15px;
    margin-top: 15px;
    border-left: 2px solid var(--accent-copper);
    background: var(--accent-brass-glow);
    white-space: pre-wrap;
    font-family: var(--font-body);
}

.reflection-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

/* ==========================================================================
   TRAIL NAVIGATION & ACTION (Copper Dividers)
   ========================================================================== */
.trail-navigation { 
    display: grid; 
    grid-template-columns: 1fr auto 1fr; 
    align-items: center;
    margin-top: 2rem;
    padding-top: 1.5rem;
    margin-bottom: 2rem;
    margin-left: 2.5rem;
    margin-right: 2.5rem;
    border-top: 3px double var(--accent-copper); 
}

.trail-navigation > :first-child { justify-self: start; }
.trail-navigation > :nth-child(2) { justify-self: center; }
.trail-navigation > :last-child { justify-self: end; }

.reset-container { 
    display: flex; 
    justify-content: space-between;
    align-items: center;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 3px double var(--accent-copper);
    width: 100%; 
}

.data-warning {
    text-align: center;
    display: block;
    margin: 0.5rem auto;
    width: 100%;
    color: var(--accent-warning);
    font-size: 1rem;
}

/* ==========================================================================
   FOOTER & SOCIAL
   ========================================================================== */
.social-links {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 1rem;
}

.social-icon {
    color: var(--accent-copper);
    font-size: 1.2rem;
    text-decoration: none;
    transition: all 0.3s ease;
    border-radius: 50%; 
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px; 
    height: 44px; 
}

@media (hover: hover) {
	.social-icon:hover {
	background-color: var(--accent-brass-glow);
}

#scrollTopBtn:hover {
	background-color: var(--accent-brass);
	color: var(--bg-surface);
}

}

.copyright {
	text-align: center;
	color: var(--accent-copper);
	font-size: 1rem;
}

#scrollTopBtn {
    opacity: 0;           
    pointer-events: none; 
    position: fixed;
    bottom: 30px;
    right: 40px;
    z-index: 99;
    border: 1px solid var(--accent-brass); 
    background-color: var(--bg-surface); 
    color: var(--accent-brass); 
    width: 44px; 
    height: 44px; 
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.3s ease;
}

/* ==========================================================================
   RESPONSIVE & PRINT MEDIA QUERIES
   ========================================================================== */
@media (max-width: 768px) {
    body {
        font-size: 1.25rem;
        line-height: 1.65;
    }

    #pap {
        padding: 1.5rem 1rem;
        border: none;
    }

    main p {
        margin-left: 0;
        margin-right: 0;
    }

    .reflection-section { 
        margin-left: 0;
        margin-right: 0;
    }

    /* Add .reflection-actions here alongside .trail-navigation */
    .trail-navigation, .reflection-actions {
        display: flex;
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
        margin-left: 0;
        margin-right: 0;
    }
    
    .nav-btn, .action-tool-link, .reflect-btn, .action-btn {
        width: 100%;
        text-align: center;
    }
    
    .reset-container {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    #scrollTopBtn {
        right: 20px;
        bottom: 20px;
    }
}

@media print {
    body {
		background: white;
		color: black;
	}
    
	#pap {
		box-shadow: none;
		border: none;
		padding: 0;
	}
    
	#stats-container, .tree-controls, .trail-navigation, .reflect-btn, .action-container, .reset-container, #scrollTopBtn, .reflection-box, .data-warning, .breadcrumbs, .trail-markers, .social-links {
		display: none;
	}
    
	.print-reflection-output {
		display: block;
		border-color: #ccc;
		background: none;
	}
    
	main p {
		page-break-inside: avoid;
		orphans: 3; 
        widows: 3;
	}
}