/*
Theme Name: TexTradeUK Block
Theme URI: https://github.com/marijustechin/textradeuk-block
Author: MarijusTechin
Author URI: https://github.com/marijustechin
Description: TexTradeUK Block emphasizes simplicity and adaptability.
Requires at least: 6.7
Tested up to: 7.0
Requires PHP: 7.2
Version: 1.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: textradeuk
Tags: custom-colors, custom-menu, custom-logo, featured-images, block-styles, accessibility-ready, blog
*/

/*
 * Progressive enhancement to reduce widows and orphans
 * https://github.com/WordPress/gutenberg/issues/55190
 */
h1,
h2,
h3,
h4,
h5,
h6,
blockquote,
caption,
figcaption,
p {
    text-wrap: pretty;
}

/*
 * Change the position of the more block on the front, by making it a block level element.
 * https://github.com/WordPress/gutenberg/issues/65934
*/
.wp-block-post-excerpt__more-link {
    display: block;
}

/* Navigation */
.wp-block-navigation .wp-block-navigation-item__content:hover {
    text-decoration: none; /* Turn off the default underline */
    border-bottom: 2px solid var(--wp--preset--color--dark-green);
    padding-bottom: 0.25rem; /* This creates the "distance" */
    display: inline-block; /* Ensures the border stays tight to the text */
}

/* Target the link that is currently the active page */
.wp-block-navigation .wp-block-navigation-item__content[aria-current="page"] {
    text-decoration: none; /* Turn off the default underline */
    border-bottom: 2px solid var(--wp--preset--color--dark-green);
    color: var(--wp--preset--color--dark-green);
    padding-bottom: 0.25rem; /* This creates the "distance" */
    display: inline-block; /* Ensures the border stays tight to the text */
    pointer-events: none; /* Disables all mouse interactions/clicks */
    cursor: default; /* Ensures the pointer doesn't turn into a hand */
    user-select: none; /* Prevents accidental highlighting */
}

/* Turn the last link into a clean B2B ghost button */
.wp-block-navigation
    .wp-block-navigation-item:last-child
    .wp-block-navigation-item__content {
    border: 2px solid var(--wp--preset--color--dark-green);
    color: var(--wp--preset--color--dark-green);
    padding: 0.4rem 1.25rem;
    border-radius: 50px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease;
}

/* Subtle background shift on hover */
.wp-block-navigation
    .wp-block-navigation-item:last-child
    .wp-block-navigation-item__content:hover {
    background-color: var(--wp--preset--color--dark-green);
    color: #ffffff;
    border-bottom: 2px solid var(--wp--preset--color--dark-green); /* Prevents layout jump */
}

/* ==========================================================================
   Footer Navigation Overrides (Fixes Conflict)
   ========================================================================== */

/* 1. Reset text layout properties for footer links */
.site-footer .wp-block-navigation-item__content {
    color: #ffffff !important; /* Force text to stay white on dark background */
    border-bottom: none !important; /* Remove the underline border from header logic */
    padding-bottom: 0 !important;
    display: inline !important;
    pointer-events: auto !important; /* Allow users to click the link */
    cursor: pointer !important;
    user-select: auto !important;
}

/* 2. Simple hover effect for footer links */
.site-footer .wp-block-navigation-item__content:hover {
    color: #ffffff !important;
    text-decoration: underline !important; /* Simple classic underline on hover */
    border-bottom: none !important;
}

/* 3. Handle the active/current page item specifically in the footer */
.site-footer .wp-block-navigation-item__content[aria-current="page"] {
    color: #ffffff !important;
    font-weight: 700; /* Make active link bold instead of hiding or breaking it */
    text-decoration: none !important;
    border-bottom: none !important;
    pointer-events: none !important;
}

/* Blog list */
ul.blog-query-grid.wp-block-post-template > li {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    border: 2px solid var(--wp--preset--color--dark-green, #0b4f4a);
    border-radius: 12px;
    background-color: #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    transition:
        box-shadow 0.25s ease,
        transform 0.25s ease;
}

ul.blog-query-grid.wp-block-post-template > li:hover {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    transform: translateY(-2px);
}

ul.blog-query-grid.wp-block-post-template > li > figure {
    flex-shrink: 0;
    margin: 0;
    aspect-ratio: 16 / 9;
}

ul.blog-query-grid.wp-block-post-template > li > figure img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Constrain post title to 2 lines */
ul.blog-query-grid.wp-block-post-template .wp-block-post-title {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    padding: 0 1.5rem;
}

/* Force the post excerpt or the block right above the "Read more" link to expand */
ul.blog-query-grid.wp-block-post-template .wp-block-post-excerpt {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    padding: 0 1.5rem 1.5rem;
}

.contact-item-icon {
    color: var(--wp--preset--color--accent);
}
