/* ===========================================
   HAWKSBURY TIMBER REFERENCE
   AOTP Style - Matching AOTP reference library styling exactly
   Version: 20260205-020 - Added next/previous chapter pagination links
   =========================================== */

/* --- Design Tokens --- */
.htr-page-wrap {
    --htr-navy: #2D3748; /* AOTP navy */
    --htr-gold: #E6C261; /* AOTP gold */
    --htr-primary: #2D3748;
    --htr-accent: #E6C261;
    --htr-yellow: #E6C261; /* AOTP gold for h2 underlines */
    --htr-bg: #f4f1ea; /* AOTP paper */
    --htr-bg-alt: #eae8e0;
    --htr-sidebar-bg: #f4f1ea; /* AOTP paper for sidebars */
    --htr-white: #ffffff;
    --htr-text: #2D3748; /* AOTP ink */
    --htr-text-light: #555555;
    --htr-border: #d0d0d0;

    --htr-font: var(--font-primary, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif);
    --htr-font-heading: var(--font-heading, Georgia, "Times New Roman", Times, serif);
    --htr-font-mono: "IBM Plex Mono", monospace;
}

/* --- Page Wrapper --- */
.htr-page-wrap {
    background: var(--htr-bg) !important; /* AOTP paper background */
    min-height: 60vh;
    padding: 0;
    padding-bottom: 60px !important; /* Add spacing before footer */
    margin-bottom: 0 !important;
}

/* Ensure body background matches on reference pages */
body.htr-reference {
    background-color: var(--htr-bg) !important;
}

body.htr-reference #page {
    background-color: var(--htr-bg) !important;
}

body.htr-reference .site-main {
    background-color: var(--htr-bg) !important;
    padding-bottom: 0 !important;
    margin-bottom: 0 !important;
}

/* Footer stays dark - don't override background */
/* Ensure proper spacing between content and footer */
body.htr-reference .htr-page-wrap + .site-footer {
    margin-top: 0 !important; /* Footer margin handled by page-wrap padding */
}


/* --- Layout --- */
.htr-layout {
    display: flex;
    gap: 28px;
    max-width: 1140px;
    width: 100%;
    margin: 0 auto;
    padding: 0 24px;
    align-items: flex-start;
    box-sizing: border-box;
    font-family: var(--htr-font);
    font-size: 16px;
    line-height: 1.7;
    color: var(--htr-text);
}

/* Add minimal top spacing so content doesn't sit flush with header */
.htr-page-wrap > .htr-layout {
    padding-top: 20px;
}

.htr-layout--single-col {
    display: block;
}

.htr-layout--single-col .htr-main {
    width: 100%;
    max-width: 100%;
}

/* --- Sidebars --- */
.htr-side {
    flex: 0 0 240px; /* AOTP sidebar width */
    background: var(--htr-sidebar-bg);
    align-self: flex-start;
    border: 4px solid var(--htr-navy);
    box-shadow: 8px 8px 0 rgba(45, 55, 72, 0.15);
}

/* --- Main Content --- */
.htr-main {
    flex: 1;
    min-width: 0;
    background: var(--htr-bg); /* AOTP paper background */
    border: 4px solid var(--htr-navy);
    box-shadow: 8px 8px 0 rgba(45, 55, 72, 0.15);
    padding: 0;
}

/* --- Back Link --- */
.htr-back {
    padding: 18px 50px;
    border-bottom: 1px solid rgba(45, 55, 72, 0.2);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
}

.htr-back a {
    color: var(--htr-gold); /* AOTP gold */
    text-decoration: none;
    font-family: var(--htr-font-mono); /* Monospace font */
    font-size: 0.875rem;
    font-weight: 600;
    display: inline-block;
}

.htr-back a:hover {
    text-decoration: underline;
}

/* --- Hero Section --- */
.htr-hero {
    background: var(--htr-navy); /* AOTP navy */
    padding: 40px 50px;
    border-bottom: 6px solid var(--htr-gold); /* AOTP gold accent */
    position: relative;
}

/* Guide hero - centered text */
.htr-hero--guide {
    text-align: center;
}

.htr-hero::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 8px;
    background: var(--htr-gold);
}

.htr-hero .htr-title {
    font-family: var(--htr-font-heading, var(--font-heading, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif)) !important;
    font-size: 2rem !important;
    font-weight: 800 !important;
    margin: 0 0 1.5rem 0 !important;
    color: #ffffff !important;
    line-height: 1.3 !important;
    letter-spacing: 0 !important;
    text-transform: uppercase !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: relative;
    padding-left: 0;
}

/* Guide hero description - lighter white text on blue background */
.htr-hero--guide .htr-hero__description {
    color: rgba(255, 255, 255, 0.85);
    font-size: clamp(1rem, 2vw, 1.25rem);
    line-height: 1.7;
    max-width: 800px;
    margin: 0 auto;
    font-family: var(--htr-font, var(--font-primary, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif));
}

.htr-hero--guide .htr-hero__description p {
    margin: 0;
}

.htr-hero--guide .htr-hero__description p + p {
    margin-top: 1rem;
}

.htr-hero__meta {
    font-family: var(--htr-font-mono);
    font-size: 0.7rem;
    color: var(--htr-gold); /* AOTP gold */
    text-transform: uppercase;
    letter-spacing: 0.12em;
    margin-bottom: 12px;
    font-weight: 500;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.htr-chapter-progress {
    font-family: var(--htr-font-mono); /* Monospace font */
    display: inline-block;
    margin: 0;
}

.htr-views {
    font-family: var(--htr-font-mono); /* Monospace font */
    display: inline-block;
    color: inherit; /* Inherit gold color from parent */
}

/* --- Index Page Hero --- */
.htr-index-hero {
    background: transparent !important;
    padding: 60px 32px 40px;
    text-align: center;
    border-bottom: none;
}

/* CRITICAL: Index title must be dark - override white from .htr-hero .htr-title */
.htr-index-hero .htr-title,
.htr-index-hero.htr-hero .htr-title,
.htr-hero.htr-index-hero .htr-title,
.htr-page-wrap .htr-index-hero .htr-title {
    font-size: clamp(2.5rem, 6vw, 4rem) !important;
    color: var(--htr-navy) !important;
    font-family: var(--htr-font-heading, var(--font-heading, Georgia, serif)) !important;
    font-weight: 800 !important;
    line-height: 1.2 !important;
    letter-spacing: 0.05em !important;
    text-transform: uppercase !important;
}

.htr-index-subtitle {
    font-family: var(--htr-font);
    font-size: clamp(0.875rem, 1.5vw, 1rem);
    color: var(--htr-gold);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    margin: 1.5rem 0 0;
}

.htr-index-rule {
    height: 1px;
    background: var(--htr-primary);
    margin: 32px auto 0;
    max-width: 1140px;
    width: calc(100% - 64px);
}

/* --- Content Area --- */
.htr-content {
    padding: 32px 24px;
    font-size: 1.05rem;
    line-height: 1.8;
}

.htr-content h2 {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--htr-navy);
    margin: 50px 0 20px 0;
    padding-bottom: 12px;
    border-bottom: 3px solid var(--htr-gold);
    font-family: var(--htr-font-heading, var(--font-heading, -apple-system, BlinkMacSystemFont, sans-serif));
    line-height: 1.3;
}

.htr-content h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--htr-primary);
    margin: 24px 0 12px;
    font-family: var(--htr-font-heading, var(--font-heading, -apple-system, BlinkMacSystemFont, sans-serif));
}

.htr-content p {
    margin: 0 0 16px;
}

.htr-content ul,
.htr-content ol {
    margin: 0 0 16px;
    padding-left: 24px;
}

.htr-content li {
    margin-bottom: 6px;
}

/* --- Section --- */
.htr-section {
    margin-bottom: 40px;
}

.htr-section h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--htr-primary);
    margin: 0 0 24px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--htr-primary);
    font-family: var(--font-heading, Georgia, serif);
    line-height: 1.3;
}

.htr-section:last-child {
    margin-bottom: 0;
}

/* --- Guide Navigation (Left Sidebar) --- */
.htr-side .htr-guide-nav__title,
.htr-guide-nav__title {
    font-family: var(--htr-font-mono) !important;
    font-size: 0.75rem !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.15em !important;
    color: var(--htr-navy) !important;
    padding: 20px !important;
    margin: 0 !important;
    background-color: var(--htr-sidebar-bg) !important;
    border-bottom: 2px solid var(--htr-navy) !important;
}

.htr-guide-nav__list {
    list-style: none;
    margin: 0;
    padding: 0;
    background: var(--htr-sidebar-bg);
}

.htr-guide-nav__item a {
    display: block;
    padding: 12px 18px;
    color: var(--htr-text);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 400;
    border-left: 3px solid transparent;
    border-bottom: 1px solid #e2e8f0;
    background: var(--htr-sidebar-bg);
    transition: all 0.2s ease;
    line-height: 1.5;
}

.htr-guide-nav__item:last-child a {
    border-bottom: none;
}

.htr-guide-nav__item a:hover {
    background-color: #f7fafc;
    color: var(--htr-navy);
    border-left-color: var(--htr-navy);
}

.htr-side .htr-guide-nav__item.is-current > a,
.htr-side .htr-guide-nav__item.is-current a,
.htr-guide-nav__item.is-current > a,
.htr-guide-nav__item.is-current a {
    background-color: #FFF9E6 !important; /* AOTP light gold highlight */
    color: var(--htr-navy) !important;
    border-left-color: var(--htr-gold) !important;
    font-weight: 700 !important;
}

/* Add separator for first current item to distinguish from header */
.htr-guide-nav__item:first-child.is-current > a {
    border-top: 3px solid rgba(255, 255, 255, 0.2) !important;
    margin-top: 4px !important;
    position: relative;
}

.htr-guide-nav__item:first-child.is-current > a::before {
    content: '';
    position: absolute;
    top: -4px;
    left: 0;
    right: 0;
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
}

.htr-side .htr-guide-nav__item.is-current,
.htr-guide-nav__item.is-current {
    background: #1a1a1a !important;
    background-color: #1a1a1a !important;
}

/* --- Table of Contents (Right Sidebar) --- */
.htr-side .htr-toc h3,
.htr-toc h3 {
    font-family: var(--htr-font-mono) !important;
    font-size: 0.75rem !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.15em !important;
    color: var(--htr-navy) !important;
    padding: 20px !important;
    margin: 0 !important;
    background-color: var(--htr-sidebar-bg) !important;
    border-bottom: 2px solid var(--htr-navy) !important;
}

.htr-toc__list {
    list-style: none;
    margin: 0;
    padding: 8px 16px 16px;
    background: var(--htr-sidebar-bg);
}

.htr-toc__list a {
    display: block;
    padding: 12px 18px;
    color: var(--htr-text);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 400;
    border-left: 3px solid transparent;
    border-bottom: 1px solid #e2e8f0;
    transition: all 0.2s ease;
    line-height: 1.5;
}

.htr-toc__list li:last-child a {
    border-bottom: none;
}

.htr-toc__list a:hover {
    background-color: #f7fafc;
    color: var(--htr-navy);
    border-left-color: var(--htr-navy);
}

.htr-toc__list a:hover {
    color: var(--htr-accent);
}

/* --- Card Grid --- */
.htr-card-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

/* --- Cards --- */
.htr-card {
    background: var(--htr-white);
    border: 1px solid var(--htr-border);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.htr-card:hover {
    border-color: var(--htr-accent);
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.htr-card__media {
    height: 280px;
    background: var(--htr-bg-alt);
    overflow: hidden;
}

.htr-card__media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.htr-card__media--empty {
    display: flex;
    align-items: center;
    justify-content: center;
}

.htr-card__media--empty::before {
    content: '🌲';
    font-size: 2.5rem;
    opacity: 0.25;
}

.htr-card__body {
    padding: 24px;
}

.htr-card__title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--htr-primary);
    margin: 0 0 8px;
    line-height: 1.3;
    font-family: var(--htr-font-heading, var(--font-heading, -apple-system, BlinkMacSystemFont, sans-serif));
}

.htr-card__text {
    font-size: 0.875rem;
    color: var(--htr-text-light);
    margin: 0 0 14px;
    line-height: 1.5;
}

.htr-card__link {
    display: inline-block;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--htr-primary);
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 10px 20px;
    border: 2px solid var(--htr-primary);
    transition: all 0.2s ease;
}

.htr-card__link:hover {
    background: var(--htr-primary);
    color: var(--htr-white);
}

/* --- Helpful Feedback Box --- */
.htr-helpful {
    background: var(--htr-bg-alt);
    padding: 32px;
    margin: 32px 0 0;
    text-align: center;
}

.htr-helpful__question {
    display: block;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--htr-primary);
    margin-bottom: 20px;
}

.htr-helpful__actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 16px;
}

.htr-helpful__btn {
    background: var(--htr-white);
    border: 2px solid var(--htr-primary);
    color: var(--htr-primary);
    padding: 12px 28px;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
}

.htr-helpful__btn:hover {
    background: var(--htr-primary);
    color: var(--htr-white);
}

.htr-helpful__counts {
    font-size: 0.8rem;
    color: var(--htr-text-light);
}

.htr-helpful__thanks {
    display: block;
    margin-top: 12px;
    font-weight: 700;
    color: var(--htr-accent);
}

/* --- Chapter Pagination --- */
.htr-chapter-pagination {
    display: flex;
    justify-content: space-between;
    padding: 0 24px 60px 24px;
    gap: 25px;
    margin-top: 40px;
}

.htr-next-chapter,
.htr-prev-chapter {
    flex: 1;
    max-width: 48%;
}

.htr-next-chapter a,
.htr-prev-chapter a {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--htr-navy);
    color: #fff !important;
    padding: 18px 28px;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.85rem;
    text-align: center;
    border-bottom: 4px solid var(--htr-gold);
    box-shadow: 6px 6px 0 rgba(45, 55, 72, 0.15);
    transition: all 0.2s ease;
    font-family: var(--htr-font, var(--font-primary, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif));
    line-height: 1.5;
    min-height: 60px;
}

.htr-next-chapter a:hover,
.htr-prev-chapter a:hover {
    transform: translate(-2px, -2px);
    box-shadow: 8px 8px 0 rgba(45, 55, 72, 0.2);
}

.htr-next-chapter a:active,
.htr-prev-chapter a:active {
    transform: translate(0, 0);
    box-shadow: 4px 4px 0 rgba(45, 55, 72, 0.15);
}

/* --- Index Lists --- */
.htr-index__list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.htr-index__list li {
    padding: 12px 0;
    border-bottom: 1px solid var(--htr-border);
}

.htr-index__list li:last-child {
    border-bottom: none;
}

.htr-index__list a {
    color: var(--htr-text);
    text-decoration: none;
    font-weight: 600;
}

.htr-index__list a:hover {
    color: var(--htr-accent);
}

/* ===========================================
   RESPONSIVE
   =========================================== */

@media (min-width: 600px) {
    .htr-card-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 900px) {
    .htr-card-grid--index {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 900px) {
    .htr-layout {
        flex-direction: column;
        gap: 20px;
        margin: 28px auto;
        padding: 0 16px;
    }

    .htr-side {
        width: 100%;
        flex: 0 0 auto;
    }

    .htr-main {
        width: 100%;
    }

    .htr-hero {
        padding: 24px;
    }

    .htr-title {
        font-size: 1.4rem;
    }

    .htr-index-hero {
        padding: 28px 24px 0;
    }

    .htr-index-hero .htr-title,
    .htr-index-hero.htr-hero .htr-title {
        font-size: 1.5rem !important;
        color: #1a1a1a !important;
    }

    .htr-index-rule {
        margin: 20px 24px 0;
    }

    .htr-content {
        padding: 24px;
    }

    .htr-helpful {
        padding: 24px;
        margin: 24px 0 0;
    }

    .htr-helpful__actions {
        flex-direction: column;
        gap: 10px;
    }

    .htr-helpful__btn {
        width: 100%;
    }

    .htr-chapter-pagination {
        flex-direction: column;
        padding: 0 24px 30px 24px;
    }

    .htr-next-chapter,
    .htr-prev-chapter {
        max-width: 100%;
    }

    .htr-next-chapter a,
    .htr-prev-chapter a {
        width: 100%;
    }

    .htr-card__media {
        height: 200px;
    }

    .htr-card__body {
        padding: 20px;
    }

    .htr-back {
        padding: 12px 24px;
    }
}

@media (max-width: 480px) {
    .htr-layout {
        padding: 0 12px;
    }

    .htr-card-grid {
        grid-template-columns: 1fr;
    }

    .htr-card__body {
        padding: 16px;
    }
}
