/* --- Modern Design System & Variables --- */
:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #eef2ff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --bg-page: #f8fafc;
    --bg-surface: #ffffff;
    --border-color: #e2e8f0;
    --border-hover: #cbd5e1;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.08);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    font-family: var(--font-stack);
    margin: 0;
    line-height: 1.6;
    background-color: var(--bg-page);
    color: var(--text-main);
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--primary-hover);
}

/* --- Header & Navigation --- */
header {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(8px);
    background-color: rgba(255, 255, 255, 0.95);
}

nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1280px;
    margin: 0 auto;
    padding: 0.85rem 2rem;
}

.logo a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-main);
}

.logo-icon {
    font-size: 1.5rem;
}

nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

nav ul li a {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.95rem;
    padding: 0.35rem 0.6rem;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

nav ul li a:hover,
nav ul li a.active-nav {
    color: var(--primary);
    background-color: var(--primary-light);
}

/* --- Hero Sections --- */
#hero {
    text-align: center;
    padding: 4.5rem 2rem 4rem;
    background: linear-gradient(180deg, #ffffff 0%, #f1f5f9 100%);
    border-bottom: 1px solid var(--border-color);
}

.hero-content {
    max-width: 820px;
    margin: 0 auto;
}

.hero-badge {
    display: inline-block;
    padding: 0.35rem 0.95rem;
    background-color: var(--primary-light);
    color: var(--primary);
    font-size: 0.82rem;
    font-weight: 700;
    border-radius: 999px;
    margin-bottom: 1.25rem;
    letter-spacing: 0.4px;
    text-transform: uppercase;
}

.hero-content h1 {
    font-size: 2.85rem;
    line-height: 1.15;
    font-weight: 800;
    letter-spacing: -0.8px;
    margin-bottom: 1.2rem;
    color: var(--text-main);
}

.hero-content p {
    font-size: 1.18rem;
    color: var(--text-muted);
    margin: 0 auto 2.2rem;
    line-height: 1.6;
}

.hero-buttons {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.templates-hero {
    text-align: center;
    padding: 3rem 2rem 2rem;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    border-bottom: 1px solid var(--border-color);
}

.templates-hero h1 {
    font-size: 2.35rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    margin: 0.5rem 0 0.75rem;
}

.templates-hero p {
    font-size: 1.08rem;
    color: var(--text-muted);
    max-width: 680px;
    margin: 0 auto 1.5rem;
}

.hero-action-row {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

/* --- Buttons --- */
.cta-button {
    background-color: var(--primary);
    color: #fff;
    padding: 0.65rem 1.3rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.92rem;
    border: 1px solid transparent;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    text-align: center;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
}

.cta-button:hover {
    background-color: var(--primary-hover);
    color: #fff;
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.secondary-button {
    background-color: #fff;
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.secondary-button:hover {
    background-color: var(--bg-page);
    border-color: var(--border-hover);
    color: var(--primary);
}

.info-button {
    background-color: #f1f5f9;
    color: var(--text-main);
    padding: 0.45rem 0.85rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    border: 1px solid var(--border-color);
    cursor: pointer;
    font-size: 0.82rem;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.info-button:hover {
    background-color: #e2e8f0;
}

.print-button {
    background-color: #059669;
    color: #fff;
}

.print-button:hover {
    background-color: #047857;
}

/* --- Horizontal Category Filter Navigation Bar --- */
.category-filter-nav {
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 1.5rem;
    position: sticky;
    top: 59px;
    z-index: 90;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.category-tabs-container {
    display: flex;
    justify-content: center;
    gap: 0.65rem;
    flex-wrap: wrap;
    max-width: 1280px;
    margin: 0 auto;
}

.category-tab-btn {
    background: #f8fafc;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    padding: 0.45rem 1rem;
    border-radius: 999px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    transition: all 0.2s ease;
}

.category-tab-btn:hover {
    background: #f1f5f9;
    color: var(--text-main);
    border-color: var(--border-hover);
}

.category-tab-btn.active-tab {
    background: var(--text-main);
    color: #ffffff;
    border-color: var(--text-main);
    box-shadow: var(--shadow-sm);
}

.tab-count {
    font-size: 0.75rem;
    padding: 0.15rem 0.45rem;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.08);
}

.category-tab-btn.active-tab .tab-count {
    background: rgba(255, 255, 255, 0.25);
    color: #ffffff;
}

/* --- Features Section (Horizontal Cards) --- */
#features {
    padding: 4.5rem 2rem;
    max-width: 1280px;
    margin: 0 auto;
}

.section-title-wrap {
    text-align: center;
    margin-bottom: 3rem;
}

.section-title-wrap h2 {
    font-size: 2.3rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    margin-bottom: 0.5rem;
}

.section-subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
    margin: 0;
}

.feature-cards-horizontal {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 2rem;
}

.feature-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2.2rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    transition: all 0.25s ease;
}

.feature-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--border-hover);
}

.feature-icon {
    font-size: 2.2rem;
    margin-bottom: 1rem;
}

.feature-badge {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.25rem 0.65rem;
    border-radius: var(--radius-sm);
    margin-bottom: 0.75rem;
}

.feature-foundations .feature-badge {
    background: #f0fdf4;
    color: #166534;
}

.feature-learn-to-read .feature-badge {
    background: #eef2ff;
    color: #4338ca;
}

.feature-blends .feature-badge {
    background: #ecfdf5;
    color: #047857;
}

.feature-advanced .feature-badge {
    background: #faf5ff;
    color: #7e22ce;
}

.feature-morphology .feature-badge {
    background: #eff6ff;
    color: #1d4ed8;
}

.feature-find-it .feature-badge {
    background: #fffbeb;
    color: #b45309;
}

.feature-card h3 {
    font-size: 1.35rem;
    font-weight: 700;
    margin: 0 0 0.6rem;
    color: var(--text-main);
}

.feature-card p {
    color: var(--text-muted);
    font-size: 0.98rem;
    line-height: 1.55;
    margin: 0 0 1.5rem;
    flex-grow: 1;
}

.feature-link {
    font-weight: 600;
    font-size: 0.92rem;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

/* --- Catalog & Book Collection Shelves --- */
.book-categories-container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 2.5rem 1.5rem 4rem;
    display: flex;
    flex-direction: column;
    gap: 3.5rem;
}

.book-collection-section {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-sm);
}

.collection-header {
    margin-bottom: 1.75rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.collection-title-wrap {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 0.4rem;
}

.collection-badge {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    background: #f1f5f9;
    color: var(--text-muted);
}

.collection-header h2 {
    font-size: 1.65rem;
    font-weight: 800;
    margin: 0;
    color: var(--text-main);
}

.books-wrapper {
    display: flex;
    flex-direction: column;
}

.visible-books {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

/* --- Card Styles --- */
.card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.4rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: all 0.2s ease;
    position: relative;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--border-hover);
}

.card-badge {
    align-self: flex-start;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    padding: 0.18rem 0.55rem;
    border-radius: var(--radius-sm);
    margin-bottom: 0.75rem;
}

.foundations-book-card .card-badge {
    background: #f0fdf4;
    color: #166534;
}

.rhyming-book-card .card-badge {
    background: #eef2ff;
    color: #4338ca;
}

.blends-book-card .card-badge {
    background: #ecfdf5;
    color: #047857;
}

.advanced-book-card .card-badge {
    background: #faf5ff;
    color: #7e22ce;
}

.together-book-card .card-badge {
    background: #fef3c7;
    color: #92400e;
}

.tier5-book-card .card-badge {
    background: #fdf2f8;
    color: #be185d;
}

.findIt-book-card .card-badge {
    background: #fffbeb;
    color: #b45309;
}

.card h3 {
    margin: 0 0 0.5rem;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-main);
}

.card-snippet {
    font-size: 0.88rem;
    color: var(--text-muted);
    font-style: italic;
    margin: 0 0 1rem;
    line-height: 1.4;
}

.card-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin-top: 1rem;
}

.card-actions .cta-button {
    grid-column: span 1;
}

.card-actions .info-button {
    grid-column: span 2;
}

.book-full-text-preview {
    font-size: 0.85rem;
    margin: 0.75rem 0;
    padding: 0.75rem;
    background-color: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    max-height: 160px;
    overflow-y: auto;
    line-height: 1.45;
}

.book-full-text-preview p {
    margin: 0.25rem 0;
}

/* --- Pagination Controls --- */
.pagination-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    margin-top: 2.2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.books-counter {
    font-size: 0.88rem;
    color: var(--text-muted);
    font-weight: 500;
}

.pagination-button {
    min-width: 170px;
}

/* --- Scope & Sequence Page Table Styles --- */
.scope-page {
    max-width: 1280px;
    margin: 0 auto;
    padding-bottom: 5rem;
}

.scope-container {
    padding: 2rem 1.5rem;
}

.scope-filter-bar {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    justify-content: center;
    margin-bottom: 2rem;
}

.scope-filter-btn {
    background: #ffffff;
    border: 1px solid var(--border-color);
    padding: 0.45rem 0.95rem;
    border-radius: 999px;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
}

.scope-filter-btn:hover {
    background: #f1f5f9;
    color: var(--text-main);
}

.scope-filter-btn.active {
    background: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
}

.table-responsive {
    overflow-x: auto;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.scope-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
    text-align: left;
}

.scope-table th {
    background: #f8fafc;
    color: var(--text-muted);
    padding: 1rem 1.2rem;
    border-bottom: 2px solid var(--border-color);
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.scope-table td {
    padding: 1.25rem 1.2rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: top;
    line-height: 1.5;
}

.scope-table tr:last-child td {
    border-bottom: none;
}

.tier-tag {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 0.35rem;
}

.tier-1-tag { background: #f0fdf4; color: #166534; }
.tier-2-tag { background: #eef2ff; color: #4338ca; }
.tier-3-tag { background: #ecfdf5; color: #047857; }
.tier-4-tag { background: #faf5ff; color: #7e22ce; }
.tier-5-tag { background: #eff6ff; color: #1d4ed8; }
.supplement-tag { background: #fffbeb; color: #b45309; }

.skill-subtext {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0.25rem 0 0;
}

.rule-text {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0.4rem 0 0;
}

.scope-table code {
    background: #f1f5f9;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-size: 0.84rem;
    color: #334155;
}

.scope-table ul {
    margin: 0;
    padding-left: 1.2rem;
}

.scope-table li {
    margin-bottom: 0.25rem;
}

.book-pill-list {
    list-style: none !important;
    padding: 0 !important;
    margin: 0 !important;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.book-pill-list li a {
    font-size: 0.85rem;
    font-weight: 600;
    display: inline-block;
}

.supplement-link {
    display: block;
    font-size: 0.84rem;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
}

/* --- Modal Styles --- */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(4px);
    overflow-y: auto;
}

.modal-content {
    background-color: #ffffff;
    margin: 5% auto;
    padding: 2.5rem;
    border-radius: var(--radius-lg);
    max-width: 680px;
    position: relative;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

.modal-header h3 {
    margin: 0 0 0.4rem;
    font-size: 1.5rem;
    font-weight: 800;
}

.modal-header p {
    margin: 0 0 1.5rem;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.instructions-list {
    padding-left: 1.4rem;
    margin: 0;
}

.instructions-list li {
    margin-bottom: 1rem;
    line-height: 1.55;
    color: var(--text-main);
}

.close-button {
    position: absolute;
    top: 1.25rem;
    right: 1.5rem;
    font-size: 28px;
    font-weight: bold;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
}

.close-button:hover {
    color: var(--text-main);
}

/* --- Editor Page --- */
.editor-main {
    display: flex;
    height: calc(100vh - 120px);
    min-height: 600px;
}

.toolbar {
    width: 230px;
    padding: 1.25rem;
    border-right: 1px solid var(--border-color);
    background-color: var(--bg-surface);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.toolbar button {
    width: 100%;
    padding: 0.75rem;
    border-radius: var(--radius-md);
    font-size: 0.92rem;
    font-weight: 600;
}

.toolbar-hint {
    margin-top: auto;
    padding: 0.85rem;
    background-color: var(--bg-page);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.45;
}

#canvas-container {
    flex-grow: 1;
    padding: 1.5rem;
    overflow: auto;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #cbd5e1;
}

#canvas {
    width: 11in;
    height: 8.5in;
    background-color: #ffffff;
    position: relative;
    border: 1px solid #94a3b8;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}

.page-grid {
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(2, 1fr);
}

.page-cell {
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    box-sizing: border-box;
    padding: 0.25in;
}

.page-inner-content {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    box-sizing: border-box;
}

.page-number {
    position: absolute;
    bottom: 0.15in;
    right: 0.15in;
    font-size: 0.75rem;
    font-weight: bold;
    color: #94a3b8;
}

.text-box {
    border: 1px dashed var(--primary);
    padding: 0.4rem;
    min-width: 60px;
    min-height: 24px;
    background-color: rgba(255, 255, 255, 0.92);
    font-size: 0.95rem;
    line-height: 1.35;
    color: var(--text-main);
}

.draggable-image {
    cursor: grab;
    max-width: 90px;
    max-height: 90px;
    object-fit: contain;
}

.resizable-container {
    position: absolute;
    cursor: grab;
    z-index: 10;
}

.resize-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background-color: var(--primary);
    border: 1px solid #ffffff;
    border-radius: 50%;
    z-index: 20;
}

.resize-handle.se {
    bottom: -5px;
    right: -5px;
    cursor: se-resize;
}

/* --- Footer --- */
footer {
    text-align: center;
    padding: 2.5rem 2rem;
    background-color: var(--bg-surface);
    border-top: 1px solid var(--border-color);
    font-size: 0.9rem;
    color: var(--text-muted);
}

.footer-content {
    max-width: 1280px;
    margin: 0 auto;
}

/* --- Responsive Layout --- */
@media (max-width: 992px) {
    .editor-main {
        flex-direction: column;
        height: auto;
    }
    .toolbar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        flex-direction: row;
        flex-wrap: wrap;
    }
    .toolbar button {
        width: auto;
        flex: 1;
    }
    #canvas {
        width: 92vw;
        height: calc(92vw * (8.5 / 11));
    }
}
