/**
 * Hub Builder Frontend Styles
 *
 * Theme-Compatible - Inherits all typography from theme
 */

/* ============================================
   SCOPED CSS VARIABLES
   ============================================ */
.hub-builder-content {
    --hub-heading-color: inherit;
    --hub-columns: 1;
    --hub-custom-width: 1000px;
}

/* ============================================
   DISPLAY WIDTH OPTIONS
   ============================================ */
.hub-children-wrapper {
    margin: 2em 0;
    box-sizing: border-box;
}

/* Contained (Boxed) - centered with max-width */
.hub-children-wrapper.hub-children-contained {
    max-width: 1160px !important;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
    padding-left: 15px;
    padding-right: 15px;
}

/* Full Width - spans full container width */
.hub-children-wrapper.hub-children-full-width {
    max-width: none !important;
    width: 100%;
    margin-left: 0;
    margin-right: 0;
}

/* Custom Width - uses CSS variable */
.hub-children-wrapper.hub-children-custom-width {
    max-width: var(--hub-custom-width, 1000px) !important;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
    padding-left: 15px;
    padding-right: 15px;
}

/* ============================================
   LIST LAYOUT
   ============================================ */
.hub-children-list {
    margin: 1.5em 0;
}

.hub-children-list .hub-child-item {
    margin-bottom: 1.5em;
    padding-bottom: 1.5em;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.hub-children-list .hub-child-item:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.hub-children-list .hub-child-title {
    margin: 0 0 0.5em 0;
}

.hub-children-list .hub-child-title a {
    color: var(--hub-heading-color);
    text-decoration: none;
}

.hub-children-list .hub-child-title a:hover {
    text-decoration: underline;
}

.hub-children-list .hub-child-excerpt {
    margin: 0;
}

/* ============================================
   GRID LAYOUT
   ============================================ */
.hub-children-grid {
    display: grid;
    grid-template-columns: repeat(var(--hub-columns), 1fr);
    gap: 1.5em;
    margin: 1.5em 0;
}

.hub-children-grid .hub-child-item {
    padding: 1.25em;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
}

.hub-children-grid .hub-child-title {
    margin: 0 0 0.5em 0;
}

.hub-children-grid .hub-child-title a {
    color: var(--hub-heading-color);
    text-decoration: none;
}

.hub-children-grid .hub-child-title a:hover {
    text-decoration: underline;
}

.hub-children-grid .hub-child-excerpt {
    margin: 0;
}

/* ============================================
   CARDS LAYOUT
   ============================================ */
.hub-children-cards {
    display: grid;
    grid-template-columns: repeat(var(--hub-columns), 1fr);
    gap: 1.5em;
    margin: 1.5em 0;
}

.hub-children-cards .hub-child-item {
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    overflow: hidden;
}

.hub-children-cards .hub-child-image {
    aspect-ratio: 16 / 9;
    overflow: hidden;
}

.hub-children-cards .hub-child-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.hub-children-cards .hub-child-content {
    padding: 1.25em;
}

.hub-children-cards .hub-child-title {
    margin: 0 0 0.5em 0;
}

.hub-children-cards .hub-child-title a {
    color: var(--hub-heading-color);
    text-decoration: none;
}

.hub-children-cards .hub-child-title a:hover {
    text-decoration: underline;
}

.hub-children-cards .hub-child-excerpt {
    margin: 0 0 1em 0;
}

.hub-children-cards .hub-child-link {
    color: var(--hub-heading-color);
    text-decoration: none;
}

.hub-children-cards .hub-child-link:hover {
    text-decoration: underline;
}

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

/* Tablet - max-width adjustments */
@media screen and (max-width: 1024px) {
    .hub-children-wrapper.hub-children-contained {
        max-width: 100% !important;
        padding-left: 20px;
        padding-right: 20px;
    }

    .hub-children-wrapper.hub-children-custom-width {
        max-width: 100% !important;
        padding-left: 20px;
        padding-right: 20px;
    }
}

/* Mobile - smaller padding and single column */
@media screen and (max-width: 768px) {
    .hub-children-wrapper.hub-children-contained,
    .hub-children-wrapper.hub-children-custom-width,
    .hub-children-wrapper.hub-children-full-width {
        max-width: 100% !important;
        padding-left: 15px;
        padding-right: 15px;
    }

    .hub-children-grid,
    .hub-children-cards {
        grid-template-columns: 1fr;
    }
}

/* Small mobile devices */
@media screen and (max-width: 480px) {
    .hub-children-wrapper.hub-children-contained,
    .hub-children-wrapper.hub-children-custom-width,
    .hub-children-wrapper.hub-children-full-width {
        padding-left: 10px;
        padding-right: 10px;
    }

    .hub-children-list .hub-child-item {
        padding-bottom: 1em;
        margin-bottom: 1em;
    }

    .hub-children-grid .hub-child-item {
        padding: 1em;
    }

    .hub-children-cards .hub-child-content {
        padding: 1em;
    }
}

/* ============================================
   TABLE OF CONTENTS
   ============================================ */
.hub-toc {
    margin: 1.5em 0;
    padding: 1.25em 1.5em;
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    max-width: 600px;
}

.hub-toc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1em;
    padding-bottom: 0.75em;
    border-bottom: 1px solid #e0e0e0;
}

.hub-toc-title {
    margin: 0;
    font-size: 1.1em;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5em;
}

.hub-toc-title::before {
    content: "📋";
    font-size: 1em;
}

.hub-toc-toggle {
    background: transparent;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 0.35em 0.5em;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85em;
    color: #666;
    transition: all 0.2s ease;
}

.hub-toc-toggle:hover {
    background: #e9ecef;
    border-color: #ccc;
}

.hub-toc-toggle-icon {
    display: block;
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid currentColor;
    transition: transform 0.3s ease;
}

.hub-toc-toggle[aria-expanded="false"] .hub-toc-toggle-icon {
    transform: rotate(-90deg);
}

.hub-toc-list {
    margin: 0;
    padding-left: 0;
    list-style-type: none;
    counter-reset: toc-counter;
    max-height: 1000px;
    overflow: hidden;
    transition: max-height 0.3s ease-out, opacity 0.3s ease-out;
}

.hub-toc-list[hidden] {
    display: block !important;
    max-height: 0;
    opacity: 0;
    margin: 0;
    padding: 0;
}

.hub-toc-item {
    margin: 0;
    padding: 0;
    line-height: 1.6;
    counter-increment: toc-counter;
}

.hub-toc-item.hub-toc-level-2 {
    margin-bottom: 0.25em;
}

.hub-toc-item.hub-toc-level-3 {
    padding-left: 1.5em;
    margin-bottom: 0.15em;
}

.hub-toc-item.hub-toc-level-3::before {
    content: "•";
    color: #888;
    margin-right: 0.5em;
}

.hub-toc-link {
    text-decoration: none;
    color: #333;
    display: inline-block;
    padding: 0.25em 0;
    transition: color 0.2s ease;
}

.hub-toc-item.hub-toc-level-2 > .hub-toc-link::before {
    content: counter(toc-counter) ". ";
    color: #666;
    font-weight: 500;
}

.hub-toc-link:hover {
    color: #0066cc;
    text-decoration: underline;
}

.hub-toc-sublist {
    margin: 0.25em 0 0.5em 0;
    padding-left: 1.5em;
    list-style-type: none;
}

.hub-toc-sublist .hub-toc-item::before {
    content: "•";
    color: #888;
    margin-right: 0.5em;
}

/* Smooth scroll for TOC anchors */
html {
    scroll-behavior: smooth;
}

/* Scroll offset for fixed headers */
[id] {
    scroll-margin-top: 80px;
}

/* ============================================
   FAQ ACCORDION
   ============================================ */
.hub-faq-accordion {
    margin: 1.5em 0;
}

.hub-faq-item {
    margin-bottom: 0.75em;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.hub-faq-item:hover {
    border-color: #ccc;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.hub-faq-question {
    margin: 0;
    padding: 0;
}

.hub-faq-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 15px 20px;
    background: #fafafa;
    border: none;
    text-align: left;
    font-size: inherit;
    font-weight: 500;
    text-transform: none; /* Ensure NOT uppercase */
    cursor: pointer;
    transition: background-color 0.2s ease;
    color: inherit;
    line-height: 1.5;
}

.hub-faq-trigger:hover {
    background: #f0f0f0;
}

.hub-faq-trigger:focus {
    outline: 2px solid #0066cc;
    outline-offset: -2px;
}

.hub-faq-trigger[aria-expanded="true"] {
    background: #f5f5f5;
    border-bottom: 1px solid #e0e0e0;
}

/* Chevron icon */
.hub-faq-icon {
    flex-shrink: 0;
    width: 0;
    height: 0;
    margin-left: 1em;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 7px solid #666;
    transition: transform 0.3s ease;
}

.hub-faq-trigger[aria-expanded="false"] .hub-faq-icon {
    transform: rotate(-90deg);
}

.hub-faq-trigger[aria-expanded="true"] .hub-faq-icon {
    transform: rotate(0deg);
}

.hub-faq-answer {
    padding: 0 20px;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out, padding 0.3s ease-out;
    background: #fff;
}

.hub-faq-answer:not([hidden]) {
    padding: 15px 20px;
    max-height: 1000px;
}

.hub-faq-answer[hidden] {
    display: block !important;
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
}

.hub-faq-answer p:first-child {
    margin-top: 0;
}

.hub-faq-answer p:last-child {
    margin-bottom: 0;
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    .hub-children-list,
    .hub-children-grid,
    .hub-children-cards {
        display: block;
    }

    .hub-child-item {
        break-inside: avoid;
        margin-bottom: 1em;
    }

    .hub-toc-toggle {
        display: none;
    }

    .hub-toc-list[hidden] {
        display: block !important;
    }

    .hub-faq-answer[hidden] {
        display: block !important;
    }

    .hub-faq-icon {
        display: none;
    }
}
