/* ==========================================================================
   Astaria — Layout
   ========================================================================== */

/* ── Reset & base ── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body.astaria-site {
    min-height: 100vh;
    background: var(--ast-void);
    color: var(--parch-ink);
    font-family: var(--font-body);
    font-size: var(--text-base);
    line-height: var(--leading);
    overflow-x: hidden;
    position: relative;
}

/* ── Starfield canvas ── */
.starfield {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

/* ── Skip link (accessibility) ── */
.skip-link {
    position: absolute;
    top: -100%;
    left: var(--space-md);
    background: var(--parch-bg);
    color: var(--parch-ink);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius);
    z-index: 10000;
    font-family: var(--font-ui);
    text-decoration: none;
    font-weight: 600;
}

.skip-link:focus {
    top: var(--space-md);
    outline: 3px solid var(--ast-gold);
    outline-offset: 2px;
}

/* ── Site header — REMOVED, using sidebar layout ── */

/* ── Site layout: sidebar + content ── */
.site-layout {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

/* ── Left sidebar ── */
.site-sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--space-lg);
    border-right: 1px solid var(--parch-border);
    border-radius: 0;
    z-index: 50;
    scrollbar-width: thin;
    scrollbar-color: var(--parch-border) transparent;
}

.site-sidebar::-webkit-scrollbar {
    width: 5px;
}

.site-sidebar::-webkit-scrollbar-thumb {
    background: var(--parch-border);
    border-radius: 3px;
}

.site-sidebar::after {
    /* Override parchment gold top-edge — not needed on sidebar */
    display: none;
}

/* ── Sidebar branding ── */
.sidebar-branding {
    margin-bottom: var(--space-xl);
    padding-bottom: var(--space-lg);
    border-bottom: 1px solid var(--parch-border);
    text-align: center;
}

.sidebar-branding .site-logo {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    gap: 2px;
    align-items: center;
}

.sidebar-branding .site-logo-img {
    max-width: 80%;
    height: auto;
    margin-bottom: var(--space-sm);
}

.sidebar-branding .site-title {
    font-family: var(--font-heading);
    font-size: var(--text-xl);
    font-weight: 700;
    color: var(--parch-ink);
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

.sidebar-branding .site-tagline {
    font-family: var(--font-body);
    font-size: var(--text-sm);
    color: var(--parch-ink-faded);
    font-style: italic;
    letter-spacing: 0.05em;
}

/* ── Mobile sidebar toggle ── */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: var(--space-md);
    left: var(--space-md);
    z-index: 300;
    flex-direction: column;
    gap: 5px;
    background: var(--parch-bg);
    border: 1px solid var(--parch-border);
    border-radius: var(--radius);
    cursor: pointer;
    padding: var(--space-sm);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.sidebar-toggle .nav-toggle-bar {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--parch-ink);
    border-radius: 1px;
    transition: transform var(--duration) var(--ease-out),
                opacity var(--duration) var(--ease-out);
}

.sidebar-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.sidebar-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(2) {
    opacity: 0;
}

.sidebar-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* ── Hero area ── */
.hero-area {
    position: relative;
    z-index: 1;
    min-height: 50vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-3xl) var(--space-lg);
}

/* ── Main content area ── */
.site-content {
    position: relative;
    z-index: 1;
    padding: var(--space-xl) var(--space-lg) var(--space-3xl);
    min-width: 0; /* prevent grid blowout */
}

.content-wrapper {
    max-width: var(--content-max);
    margin: 0 auto;
}

/* ── Breadcrumbs bar ── */
.breadcrumbs-bar {
    margin-bottom: var(--space-lg);
}

/* ── Content top / bottom ── */
.content-top {
    margin-bottom: var(--space-xl);
}

.content-bottom {
    margin-top: var(--space-xl);
}

/* ── Footer ── */
.site-footer {
    position: relative;
    z-index: 1;
    margin-top: var(--space-3xl);
}

.footer-inner {
    max-width: var(--content-max);
    margin: 0 auto;
    padding: var(--space-2xl) var(--space-lg);
}

.footer-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-xl);
    margin-bottom: var(--space-xl);
}

.footer-bottom {
    border-top: 1px solid var(--parch-border);
    padding-top: var(--space-lg);
    margin-bottom: var(--space-lg);
}

.footer-credit {
    text-align: center;
    font-family: var(--font-ui);
    font-size: var(--text-sm);
    color: var(--parch-ink-faded);
    border-top: 1px solid var(--parch-border);
    padding-top: var(--space-lg);
}

/* ── Joomla Pagination ── */
/* ── Joomla Pagination ── */
.pagination {
    display: flex;
    list-style: none !important;
    padding: 0;
    margin: var(--space-lg) 0 var(--space-md);
    gap: var(--space-xs);
    flex-wrap: wrap;
    justify-content: center;
}

.pagination .page-item {
    list-style: none;
}

.page-item .page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.2em;
    height: 2.2em;
    padding: var(--space-xs) var(--space-sm);
    font-family: var(--font-ui);
    font-size: var(--text-sm);
    color: var(--parch-ink-light);
    background: var(--parch-bg-light);
    border: 1px solid var(--parch-border);
    border-radius: var(--radius);
    text-decoration: none;
    transition: all var(--duration) var(--ease-out);
    cursor: pointer;
    line-height: 1;
}

.page-item .page-link:hover {
    color: var(--parch-ink);
    background: var(--parch-bg-dark);
    border-color: var(--ast-gold-dim);
}

.page-item.active .page-link {
    color: var(--parch-ink);
    background: var(--ast-gold);
    border-color: var(--ast-gold);
    font-weight: 700;
    cursor: default;
}

.page-item.disabled .page-link {
    color: var(--parch-ink-faded);
    background: transparent;
    border-color: var(--parch-border);
    opacity: 0.4;
    cursor: default;
}

/* Joomla icon-font arrow replacements */
[class^="icon-angle-"],
[class*=" icon-angle-"],
.icon-chevron-right {
    font-style: normal;
    font-size: var(--text-base);
    line-height: 1;
}

.icon-angle-double-left::before  { content: "\00AB"; }
.icon-angle-left::before         { content: "\2039"; }
.icon-angle-right::before        { content: "\203A"; }
.icon-angle-double-right::before { content: "\00BB"; }
.icon-chevron-right::before      { content: "\203A"; margin-right: 0.3em; }

/* Page counter text — redundant with pagination buttons */
.com-content-category-blog__counter {
    display: none;
}

/* Blog "more items" links list */
.items-more {
    margin-top: var(--space-lg);
    padding-top: var(--space-md);
    border-top: 1px solid var(--parch-border);
}

.items-more ol.com-content-blog__links {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm) var(--space-lg);
}

.com-content-blog__link a {
    font-family: var(--font-ui);
    font-size: var(--text-sm);
    color: var(--ast-celestial-dim);
    text-decoration: none;
    transition: color var(--duration) var(--ease-out);
}

.com-content-blog__link a:hover {
    color: var(--ast-gold);
}

/* Joomla icon stubs — prevent missing icon blanks */
.icon-folder-open::before { content: "\25A1"; margin-right: 0.3em; font-style: normal; }
.icon-search::before      { content: "\2315"; font-style: normal; }
.icon-fw { margin-right: 0.2em; }

/* ── Images ── */
img {
    max-width: 100%;
    height: auto;
}

/* ==========================================================================
   Hero Banner — Homepage hero section (module position: hero)
   ========================================================================== */

.hero-area {
    position: relative;
    text-align: center;
    padding: var(--space-3xl) var(--space-xl) var(--space-2xl);
    margin-bottom: var(--space-xl);
}

.hero-banner {
    max-width: 700px;
    margin: 0 auto;
}

/* Logo placeholder */
.hero-logo-placeholder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 160px;
    height: 160px;
    margin: 0 auto var(--space-lg);
    border: 2px dashed var(--ast-gold-dim);
    border-radius: 50%;
    color: var(--ast-gold-dim);
    font-family: var(--font-ui);
    font-size: var(--text-sm);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    background: rgba(196, 163, 90, 0.06);
}

/* Title */
.hero-title {
    font-family: var(--font-heading);
    font-size: var(--text-hero);
    color: var(--ast-gold);
    margin: 0 0 var(--space-xs);
    letter-spacing: 0.08em;
    text-shadow:
        0 0 30px rgba(196, 163, 90, 0.3),
        0 0 60px rgba(196, 163, 90, 0.1);
    line-height: var(--leading-tight);
}

/* Subtitle */
.hero-subtitle {
    font-family: var(--font-ui);
    font-size: var(--text-xl);
    color: var(--ast-starlight);
    margin: 0 0 var(--space-lg);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    font-weight: 400;
}

/* Tagline */
.hero-tagline {
    font-family: var(--font-body);
    font-size: var(--text-lg);
    color: var(--ast-stardust);
    margin: 0 0 var(--space-2xl);
    line-height: var(--leading);
    opacity: 0.85;
}

/* CTA button group */
.hero-cta-group {
    display: flex;
    gap: var(--space-md);
    justify-content: center;
    flex-wrap: wrap;
}

/* CTA base */
.hero-cta {
    display: inline-block;
    font-family: var(--font-ui);
    font-size: var(--text-base);
    padding: 0.75em 2em;
    border-radius: var(--radius);
    text-decoration: none;
    letter-spacing: 0.06em;
    transition: all 0.3s ease;
    cursor: pointer;
    border: 2px solid var(--ast-gold);
}

/* Primary CTA — gold filled */
.hero-cta-primary {
    background: var(--ast-gold);
    color: var(--ast-void);
    border-color: var(--ast-gold);
}

.hero-cta-primary:hover,
.hero-cta-primary:focus-visible {
    background: var(--ast-stardust);
    border-color: var(--ast-stardust);
    color: var(--ast-void);
    box-shadow: 0 0 20px rgba(196, 163, 90, 0.4);
}

/* Secondary CTA — outline */
.hero-cta-secondary {
    background: transparent;
    color: var(--ast-gold);
    border-color: var(--ast-gold);
}

.hero-cta-secondary:hover,
.hero-cta-secondary:focus-visible {
    background: rgba(196, 163, 90, 0.12);
    color: var(--ast-stardust);
    border-color: var(--ast-stardust);
    box-shadow: 0 0 20px rgba(196, 163, 90, 0.2);
}

/* Decorative divider below hero */
.hero-area::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 120px;
    height: 1px;
    background: linear-gradient(
        90deg,
        transparent,
        var(--ast-gold-dim),
        var(--ast-gold),
        var(--ast-gold-dim),
        transparent
    );
}

/* ── Focus styles (accessibility) ── */
:focus-visible {
    outline: 2px solid var(--ast-gold);
    outline-offset: 2px;
}

/* ==========================================================================
   GUI Toggle Classes — controlled by template params
   ========================================================================== */

/* ── Sidebar Right ── */
.sidebar-right .site-layout {
    grid-template-columns: 1fr var(--sidebar-w);
}

.sidebar-right .site-sidebar {
    order: 2;
    border-right: none;
    border-left: 1px solid var(--parch-border);
}

.sidebar-right .site-content {
    order: 1;
}

@media (max-width: 768px) {
    .sidebar-right .site-sidebar {
        left: auto;
        right: 0;
        transform: translateX(100%);
        border-left: none;
    }
    .sidebar-right .site-sidebar.is-open {
        transform: translateX(0);
    }
    .sidebar-right .sidebar-toggle {
        left: auto;
        right: var(--space-md);
    }
}

/* ── No Gold Edge ── */
.no-gold-edge .parchment-surface::after {
    display: none;
}

/* ── No Drop Caps ── */
.no-drop-caps .item-page > .article-info + p::first-letter,
.no-drop-caps .item-page > p:first-of-type::first-letter {
    font-size: 1em;
    float: none;
    margin: 0;
    color: inherit;
}

/* ── No Justify ── */
.no-justify .parchment-surface p {
    text-align: left;
    hyphens: none;
}

/* ── No Heading Borders ── */
.no-heading-borders .parchment-surface h1,
.no-heading-borders .parchment-surface h2 {
    padding-bottom: 0;
    border-bottom: none;
    margin-bottom: var(--space-md);
}

/* ── No Hero Divider ── */
.no-hero-divider .hero-area::after {
    display: none;
}

/* ── No Smooth Scroll ── */
.no-smooth-scroll html {
    scroll-behavior: auto;
}

/* ── Content Spacing variants ── */
.content-spacing-compact .parchment-surface {
    padding: var(--space-lg);
}
.content-spacing-spacious .parchment-surface {
    padding: var(--space-3xl) var(--space-2xl);
}

/* ==========================================================================
   Hero — Background image overlay
   ========================================================================== */

.hero-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 0;
    pointer-events: none;
}

.hero-area .hero-banner {
    position: relative;
    z-index: 1;
}

/* ==========================================================================
   Homepage Feature Cards
   ========================================================================== */

.home-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: var(--space-lg);
    margin-bottom: var(--space-xl);
}

.home-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: var(--space-xl) var(--space-lg);
    text-decoration: none;
    color: var(--parch-ink);
    transition: transform var(--duration) var(--ease-out),
                box-shadow var(--duration) var(--ease-out);
}

.home-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3), 0 0 40px var(--parch-glow);
}

.home-card-icon {
    font-size: 2.5rem;
    margin-bottom: var(--space-md);
    display: block;
    line-height: 1;
}

.home-card-title {
    font-family: var(--font-heading);
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--parch-ink);
    margin-bottom: var(--space-sm);
    letter-spacing: 0.04em;
}

.home-card-desc {
    font-family: var(--font-body);
    font-size: var(--text-sm);
    color: var(--parch-ink-light);
    line-height: var(--leading);
    margin: 0;
}

/* ==========================================================================
   Homepage — hide main parchment (hero + cards ARE the content)
   ========================================================================== */

.astaria-home .main-parchment {
    display: none;
}

/* ==========================================================================
   Back to Top Button
   ========================================================================== */

.back-to-top {
    position: fixed;
    bottom: var(--space-xl);
    right: var(--space-xl);
    z-index: 100;
    width: 44px;
    height: 44px;
    border: 1px solid var(--ast-gold-dim);
    border-radius: 50%;
    background: var(--parch-bg);
    color: var(--parch-ink);
    font-size: var(--text-lg);
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: opacity var(--duration) var(--ease-out),
                visibility var(--duration) var(--ease-out),
                transform var(--duration) var(--ease-out),
                background var(--duration) var(--ease-out);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.back-to-top:hover {
    background: var(--ast-gold);
    color: var(--ast-void);
    border-color: var(--ast-gold);
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .starfield {
        display: none;
    }

    html {
        scroll-behavior: auto;
    }
}
