/*
Theme Name: ToolCluster Theme
Theme URI: https://toolcluster.app
Description: Custom child theme based on Twenty Twenty-Five for ToolCluster Blog.
Author: ToolCluster
Author URI: https://toolcluster.app
Template: twentytwentyfive
Version: 1.7.0
Requires at least: 6.7
Tested up to: 6.7
Requires PHP: 8.3
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: flownodehub-theme
*/

/* Hide the block-based header template part (replaced by PHP-injected header) */
header.wp-block-template-part {
    display: none !important;
}

/* ===== Header (identical to tools page) ===== */
.site-header {
    background: #0f172a;
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.header-inner {
    max-width: 1440px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    padding: 0 24px;
    height: 56px;
}

.site-logo {
    color: #fff !important;
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    text-decoration: none;
}

.site-logo:hover {
    color: #e2e8f0 !important;
}

.header-nav {
    margin-left: 40px;
    display: flex;
    gap: 24px;
}

.header-nav a {
    color: #94a3b8;
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    padding: 6px 0;
    border-bottom: 2px solid transparent;
    transition: color 0.2s, border-color 0.2s;
}

.header-nav a:hover,
.header-nav a.active {
    color: #fff;
    border-bottom-color: #2563eb;
}

/* ===== Language Switcher (identical to tools page) ===== */
.lang-switcher {
    margin-left: auto;
    position: relative;
}

.lang-current {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.06);
    color: #e2e8f0;
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.lang-current:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.25);
}

.lang-current svg {
    flex-shrink: 0;
}

.lang-chevron {
    transition: transform 0.2s;
}

.lang-switcher.open .lang-chevron {
    transform: rotate(180deg);
}

.lang-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 160px;
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    padding: 4px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    z-index: 200;
}

.lang-switcher.open .lang-dropdown {
    display: block;
    animation: langDropIn 0.15s ease-out;
}

@keyframes langDropIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.lang-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 6px;
    color: #94a3b8;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.12s;
    text-decoration: none;
}

.lang-option:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.lang-option.active {
    background: #2563eb;
    color: #fff;
}

.lang-code {
    font-weight: 700;
    font-size: 0.78rem;
    min-width: 24px;
}

.lang-name {
    font-weight: 400;
}

/* ===== Blog List Page (Cards) ===== */
.tc-blog-title {
    font-size: 1.5rem !important;
    font-weight: 700 !important;
    letter-spacing: 0.04em;
    color: #64748b;
    text-align: center !important;
    display: flex;
    align-items: center;
    gap: 20px;
}

.tc-blog-title::before,
.tc-blog-title::after {
    content: "";
    flex: 1;
    height: 1px;
    background: #cbd5e1;
}

.tc-post-grid {
    gap: 24px !important;
}

.tc-post-grid.wp-block-post-template {
    align-items: stretch !important;
}

.tc-post-grid > li {
    display: flex !important;
}

.tc-card {
    background: #fff;
    border: 1.5px solid #33363b;
    border-radius: 10px;
    overflow: hidden;
    transition: box-shadow 0.2s, transform 0.2s;
    display: flex !important;
    flex-direction: column;
    width: 100%;
}

.tc-card:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
    cursor: pointer;
}

.tc-card .wp-block-post-featured-image {
    margin: 0;
    flex-shrink: 0;
    overflow: hidden;
}

.tc-card .wp-block-post-featured-image img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
    display: block;
}

.tc-card-body {
    flex: 1;
    display: flex !important;
    flex-direction: column;
}

.tc-card-body .tc-card-date {
    margin-top: auto !important;
}

.tc-card-cat {
    margin: 0 !important;
}

.tc-card-cat a {
    display: inline-block;
    background: #eff6ff;
    color: #2563eb !important;
    font-size: 0.72rem !important;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: 4px;
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.tc-card-title {
    margin: 0 !important;
}

.tc-card-title a {
    font-size: 1.05rem !important;
    font-weight: 700 !important;
    color: #0f172a !important;
    text-decoration: none;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.tc-card-title a:hover {
    color: #2563eb !important;
}

.tc-card-excerpt {
    margin: 0 !important;
}

.tc-card-excerpt .wp-block-post-excerpt__excerpt {
    color: #64748b;
    font-size: 0.85rem !important;
    line-height: 1.55;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.tc-card-excerpt .wp-block-post-excerpt__more-link {
    display: none;
}

.tc-card-date {
    margin: 0 !important;
    color: #94a3b8 !important;
    font-size: 0.75rem !important;
    padding-top: 4px;
}

@media (max-width: 680px) {
    .tc-post-grid {
        grid-template-columns: 1fr !important;
    }
}

/* ===== Article tables: slightly smaller text for readability ===== */
.entry-content .wp-block-table,
.wp-block-post-content .wp-block-table {
    font-size: 0.95rem;
}

.entry-content .wp-block-table th:first-child,
.wp-block-post-content .wp-block-table th:first-child,
.entry-content .wp-block-table td:first-child,
.wp-block-post-content .wp-block-table td:first-child {
    text-align: center;
}

/* ===== Single post featured image: 1.91:1 SEO-optimal, no distortion ===== */
body.single .wp-block-post-featured-image img {
    aspect-ratio: 1.91 / 1;
    object-fit: cover;
    width: 100%;
    height: auto;
}

/* ===== Article Typography ===== */
.entry-content h2.wp-block-heading,
.wp-block-post-content h2.wp-block-heading {
    scroll-margin-top: 80px;
    border-left: 4px solid #2563eb;
    padding-left: 16px;
    margin-top: 2.4em;
    margin-bottom: 0.8em;
    font-size: 1.55rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: #0f172a;
    line-height: 1.35;
}

.entry-content h3.wp-block-heading,
.wp-block-post-content h3.wp-block-heading {
    margin-top: 2em;
    margin-bottom: 0.6em;
    font-size: 1.2rem;
    font-weight: 700;
    color: #1e293b;
}

.entry-content p,
.wp-block-post-content p {
    font-size: 1rem;
    line-height: 1.8;
    color: #334155;
}

/* ===== Single post: constrain post-nav & more-posts to content width ===== */
body.single .wp-block-post-navigation-link,
body.single .wp-block-group.alignwide {
    max-width: 760px !important;
    margin-left: auto !important;
    margin-right: auto !important;
}

/* ===== Footer ===== */
.fnh-footer {
    background-color: #0f172a !important;
    margin-top: 60px;
}

.fnh-footer .header-nav a {
    color: #94a3b8;
}

.fnh-footer .header-nav a:hover {
    color: #ffffff;
}

.footer-meta-nav {
    display: flex;
    gap: 16px;
}

.footer-meta-nav a {
    color: #94a3b8;
    font-size: 0.8rem;
    text-decoration: none;
}

.footer-meta-nav a:hover {
    color: #ffffff;
}

/* ===== Contact Form 7 ===== */
.wpcf7 {
    max-width: 680px;
}

.wpcf7 label {
    display: block;
    font-weight: 600;
    font-size: 0.95rem;
    color: #1e293b;
    margin-bottom: 20px;
}

.wpcf7 label .required {
    color: #dc2626;
    font-size: 0.8rem;
}

.wpcf7 input[type="text"],
.wpcf7 input[type="email"] {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 10px 14px;
    border: 1.5px solid #cbd5e1;
    border-radius: 8px;
    font-size: 0.95rem;
    background: #f8fafc;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.wpcf7 input[type="text"]:focus,
.wpcf7 input[type="email"]:focus,
.wpcf7 textarea:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
    background: #fff;
}

.wpcf7 textarea {
    display: block;
    width: 100%;
    min-height: 200px;
    margin-top: 6px;
    padding: 10px 14px;
    border: 1.5px solid #cbd5e1;
    border-radius: 8px;
    font-size: 0.95rem;
    background: #f8fafc;
    resize: vertical;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.wpcf7 input[type="submit"] {
    display: inline-block;
    padding: 12px 36px;
    background: #2563eb;
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
    margin-top: 8px;
}

.wpcf7 input[type="submit"]:hover {
    background: #1d4ed8;
}

.fnh-footer-copy {
    color: #6b7280 !important;
}

/* ===== Left Sidebar (tools-page style) ===== */
.tc-left-sidebar {
    display: none;
    position: fixed;
    top: 152px;
    left: max(12px, calc(50vw - 757px));
    width: 340px;
    z-index: 50;
    max-height: calc(100vh - 180px);
    overflow-y: auto;
    padding: 0;
}

@media (min-width: 1400px) {
    .tc-left-sidebar {
        display: block;
    }
}

/* --- Category group --- */
.tc-left-sidebar .sidebar-category {
    padding: 0 16px;
    margin-bottom: 20px;
}

/* --- Category heading (uppercase label + underline) --- */
.tc-left-sidebar .category-title {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #64748b;
    padding: 0 12px 8px;
    margin: 0 0 4px;
    border-bottom: 1px solid #e2e8f0;
}

/* --- Link list --- */
.tc-left-sidebar .category-links {
    list-style: none;
    margin: 0;
    padding: 0;
}

.tc-left-sidebar .category-links li {
    margin-bottom: 1px;
}

/* --- Individual link --- */
.tc-left-sidebar .category-links a {
    display: block;
    padding: 7px 12px;
    border-radius: 6px;
    color: #1e293b;
    font-size: 0.855rem;
    font-weight: 450;
    text-decoration: none;
    transition: all 0.12s;
}

.tc-left-sidebar .category-links a:hover {
    background: #2563eb;
    color: #fff;
}

/* Active link: current article or category page */
.tc-left-sidebar .category-links a.active {
    background: #dbeafe;
    color: #1d4ed8;
    font-weight: 600;
}

/* ===== Sidebar TOC (single posts, wide screens) ===== */
.tc-sidebar {
    display: none;
}

.tc-sidebar.ready {
    position: fixed;
    top: 152px;
    right: max(16px, calc(50vw - 736px));
    width: 320px;
    max-height: calc(100vh - 180px);
    overflow-y: auto;
    padding: 0;
}

@media (min-width: 1280px) {
    .tc-sidebar.ready {
        display: block;
    }
}

.tc-toc {
    padding: 0 16px;
}

.tc-toc-heading {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #64748b;
    padding: 0 12px 8px;
    margin: 0 0 4px;
    border-bottom: 1px solid #e2e8f0;
}

.tc-toc-link {
    display: block;
    padding: 7px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    color: #1e293b;
    font-weight: 450;
    text-decoration: none;
    line-height: 1.4;
    margin-bottom: 1px;
    transition: all 0.12s;
}

.tc-toc-link:hover {
    background: #2563eb;
    color: #fff;
}

.tc-toc-link.active {
    background: #dbeafe;
    color: #1d4ed8;
    font-weight: 600;
}

/* Ad placeholder: invisible to users, visible to logged-in admins */
.tc-ad-slot {
    display: none;
}

body.admin-bar .tc-ad-slot {
    display: block;
    margin-top: 20px;
    border: 1px dashed #cbd5e1;
    border-radius: 4px;
    padding: 8px;
    font-size: 0.6rem;
    color: #cbd5e1;
    text-align: center;
}

body.admin-bar .tc-ad-slot::after {
    content: "Ad Slot";
}

/* ===== Header nav toggle (mobile / narrow window) ===== */
.header-nav-toggle {
    display: none;
    background: none;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 6px;
    color: #e2e8f0;
    cursor: pointer;
    padding: 6px 8px;
    line-height: 1;
    margin-left: 12px;
    transition: background 0.15s;
    align-items: center;
    gap: 4px;
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 500;
}
.header-nav-toggle:hover {
    background: rgba(255,255,255,0.1);
}
.header-nav-toggle .nav-toggle-chevron {
    transition: transform 0.2s;
}
.header-nav-toggle[aria-expanded="true"] .nav-toggle-chevron {
    transform: rotate(180deg);
}

@media (max-width: 768px) {
    .header-nav-toggle {
        display: inline-flex;
    }
    .header-nav {
        display: none;
        position: absolute;
        top: 56px;
        left: 0;
        right: 0;
        background: #0f172a;
        flex-direction: column;
        padding: 4px 24px 12px;
        gap: 0;
        margin-left: 0;
        box-shadow: 0 4px 12px rgba(0,0,0,0.25);
        border-top: 1px solid rgba(255,255,255,0.08);
        z-index: 99;
    }
    .header-nav.mobile-open {
        display: flex;
        animation: navDropIn 0.15s ease-out;
    }
    .header-nav a {
        padding: 10px 0;
        border-bottom: 1px solid rgba(255,255,255,0.06);
    }
    .header-nav a:last-child {
        border-bottom: none;
    }
}
@keyframes navDropIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ===== Mobile sidebar toggle buttons ===== */
.tc-menu-toggle,
.tc-toc-toggle {
    display: none;
    background: none;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 6px;
    color: #e2e8f0;
    cursor: pointer;
    padding: 6px 8px;
    line-height: 1;
    transition: background 0.15s;
}
.tc-menu-toggle:hover,
.tc-toc-toggle:hover {
    background: rgba(255,255,255,0.1);
}
.tc-toc-toggle {
    margin-left: auto;
    margin-right: 8px;
}

@media (max-width: 1399px) {
    .tc-menu-toggle { display: inline-flex; margin-right: 12px; }
}
@media (max-width: 1279px) {
    .tc-toc-toggle { display: inline-flex; }
}

/* ===== Mobile overlay ===== */
.tc-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 80;
}
.tc-overlay.active {
    display: block;
}

/* ===== Left sidebar mobile slide-in ===== */
@media (max-width: 1399px) {
    .tc-left-sidebar.mobile-open {
        display: block;
        position: fixed;
        top: 56px;
        left: 0;
        width: 300px;
        max-height: calc(100vh - 56px);
        background: #fff;
        box-shadow: 4px 0 24px rgba(0,0,0,0.12);
        z-index: 90;
        animation: tcSlideLeft 0.2s ease-out;
        padding-top: 12px;
    }
}

@keyframes tcSlideLeft {
    from { transform: translateX(-100%); }
    to   { transform: translateX(0); }
}

@keyframes tcSlideRight {
    from { transform: translateX(100%); }
    to   { transform: translateX(0); }
}

/* ===== Callout boxes (Tip / Warning) ===== */
.tc-callout {
    position: relative;
    max-width: min(720px, 100%);
    margin: 1.6em auto;
    padding: 1.4em 1.4em 1.1em;
    border-radius: 10px;
    border: 1.5px solid;
    box-sizing: border-box;
}

.tc-callout > p {
    margin: 0 !important;
    font-size: 1rem;
    line-height: 1.8;
    color: #334155;
}

.tc-callout-label {
    position: absolute;
    top: -11px;
    left: 14px;
    padding: 2px 14px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 700;
    line-height: 1.5;
    white-space: nowrap;
}

.tc-callout-tip {
    background: #f0fdf4;
    border-color: #86efac;
}

.tc-callout-tip .tc-callout-label {
    background: #16a34a;
    color: #fff;
}

.tc-callout-warning {
    background: #fffbeb;
    border-color: #fcd34d;
}

.tc-callout-warning .tc-callout-label {
    background: #d97706;
    color: #fff;
}

/* ===== Law name highlight (inline-flow emphasis) ===== */
.tc-law-name {
    text-align: center;
    font-size: 1rem !important;
    font-weight: 700;
    color: #1e40af;
    background: linear-gradient(135deg, #eff6ff, #dbeafe);
    border: 1.5px solid #93c5fd;
    border-left: 4px solid #2563eb;
    border-radius: 8px;
    padding: 0.5em 1.2em;
    margin: 0.6em auto;
    max-width: 480px;
}

/* ===== News source citation ===== */
.tc-news-source {
    margin-top: 2em;
    padding: 1em 1.25em;
    background: #f8fafc;
    border-left: 4px solid #3b82f6;
    border-radius: 0 6px 6px 0;
    font-size: 0.9em;
    color: #475569;
}
.tc-news-source a {
    color: #2563eb;
    text-decoration: underline;
}
.tc-news-source a:hover {
    color: #1d4ed8;
}

/* ===== News archive title localisation ===== */
.tc-news-title {
    /* Inherit tc-blog-title styles */
}

/* ===== Interactive chart embed (iframe shortcode) ===== */
.tc-interactive-chart {
    margin: 24px -20px;
    max-width: calc(100% + 40px);
}
.tc-interactive-chart iframe {
    display: block;
}
@media (max-width: 768px) {
    .tc-interactive-chart {
        margin: 16px -12px;
        max-width: calc(100% + 24px);
    }
}

/* ===== Pagination centering & spacing ===== */
.wp-block-query-pagination {
    gap: 16px;
}
.wp-block-query-pagination-numbers {
    display: flex;
    gap: 8px;
}

/* ===== Right sidebar (TOC) mobile slide-in ===== */
@media (max-width: 1279px) {
    .tc-sidebar.ready.mobile-open {
        display: block;
        position: fixed;
        top: 56px;
        right: 0;
        left: auto;
        width: 280px;
        max-height: calc(100vh - 56px);
        background: rgba(255,255,255,0.98);
        backdrop-filter: blur(8px);
        box-shadow: -4px 0 24px rgba(0,0,0,0.12);
        border-radius: 0;
        z-index: 90;
        animation: tcSlideRight 0.2s ease-out;
    }
}

/* ===== Breadcrumbs ===== */
.tc-breadcrumbs {
    font-size: 0.82rem;
    line-height: 1.4;
    color: #64748b;
    padding: 0 0 4px;
    max-width: var(--wp--style--global--content-size, 650px);
    margin: 0 auto;
}
.tc-breadcrumbs ol {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0;
}
.tc-breadcrumbs li {
    display: flex;
    align-items: center;
    white-space: nowrap;
}
.tc-breadcrumbs li + li::before {
    content: "›";
    margin: 0 6px;
    color: #94a3b8;
    font-weight: 500;
}
.tc-breadcrumbs a {
    color: #475569;
    text-decoration: none;
    transition: color 0.15s;
}
.tc-breadcrumbs a:hover {
    color: #1e40af;
    text-decoration: underline;
}
.tc-breadcrumbs [aria-current="page"] {
    color: #94a3b8;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 300px;
}
@media (max-width: 600px) {
    .tc-breadcrumbs [aria-current="page"] {
        max-width: 180px;
    }
}
