/*!
Theme Name: KNICK BASE
Theme URI: https://knickdesigns.com
Description: High-performance Hybrid WP Theme. Parent of Knick Designs ecosystem.
Author: Knick Designs
Author URI: https://knickdesigns.com
Version: 1.1.0
Tested up to: 6.9
Requires PHP: 8.2
License: GPL v2 or later
Text Domain: knick_base
Tags: block-editor-styles, full-site-editing, custom-colors, custom-menu, featured-images
*/

/*--------------------------------------------------------------
>>> TABLE OF CONTENTS:
----------------------------------------------------------------
1.  Variables & Defaults
2.  Reset & Normalize
3.  Base Typography
4.  Layout & Blocks (The Hybrid Core)
    - Global Wrapper & Sticky Footer
    - Main Grid (Sidebar)
    - Block Alignments
    - Page & Full Width Logic
    - Page Templates
5.  Components
    - Forms
    - Header & Navigation
    - Content & Post Formatting
    - Sidebar & Widgets
    - Footer
6.  Utilities & Accessibility
    - Screen Reader
    - 404 Page
    - No Results / Empty State
--------------------------------------------------------------*/

/*--------------------------------------------------------------
1. Variables & Defaults
--------------------------------------------------------------*/
:root {
    /* Fallbacks if theme.json fails or plugin overrides occur */
    --kb-width-content: 840px;
    --kb-width-wide: 1200px;
    --kb-font-body: system-ui, -apple-system, sans-serif;
    
    /* Spacing Scale (Matches standard block spacing) */
    --kb-spacing-sm: 1rem;
    --kb-spacing-md: 2rem;
    --kb-spacing-lg: 4rem;
}

/*--------------------------------------------------------------
2. Reset & Normalize
--------------------------------------------------------------*/
*,
*::before,
*::after {
    box-sizing: border-box; /* The modern standard */
}

body {
    margin: 0;
    padding: 0;
    overflow-x: hidden; /* Prevents horizontal scroll from full-width blocks */
}

/* HTML5 Display Definitions */
main, header, footer, nav, section, article, aside, figure, figcaption {
    display: block;
}

/* Media Defaults */
img, svg, video, canvas, audio, iframe, embed, object {
    display: block;
    max-width: 100%;
    height: auto;
}

/*--------------------------------------------------------------
3. Base Typography
--------------------------------------------------------------*/
body {
    background-color: var(--wp--preset--color--base, #ffffff);
    color: var(--wp--preset--color--contrast, #111111);
    font-family: var(--wp--preset--font-family--primary, var(--kb-font-body));
    font-size: var(--wp--preset--font-size--medium, 1rem);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* Headings */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    margin-top: 0;
    margin-bottom: var(--kb-spacing-sm);
    line-height: 1.2;
    color: inherit;
}

h1 { font-size: var(--wp--preset--font-size--xx-large, 2.5rem); }
h2 { font-size: var(--wp--preset--font-size--x-large, 2rem); }
h3 { font-size: var(--wp--preset--font-size--large, 1.5rem); }

/* Text Elements */
p { margin-bottom: 1.5rem; }

a {
    color: var(--wp--preset--color--primary, #0073aa);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
    transition: color 0.2s ease;
}

a:hover, a:focus {
    color: var(--wp--preset--color--accent, #cd2653);
    text-decoration: none;
}

blockquote {
    margin: var(--kb-spacing-md) 0;
    padding-left: var(--kb-spacing-md);
    border-left: 4px solid var(--wp--preset--color--primary, #0073aa);
    font-style: italic;
}

pre, code, kbd, samp {
    font-family: monospace;
    font-size: 0.9em;
}

pre {
    background: #f5f5f5;
    padding: 1rem;
    overflow-x: auto;
    border-radius: 4px;
}

/*--------------------------------------------------------------
4. Layout & Blocks (Hybrid Core)
--------------------------------------------------------------*/

/* Global Wrapper & Sticky Footer Logic
--------------------------------------------- */
.site {
    display: flex;
    flex-direction: column;
    min-height: 100vh; /* Full screen height */
}

/* Fix for Admin Bar (Prevents double scrollbar) */
.admin-bar .site {
    min-height: calc(100vh - 32px);
}
@media screen and (max-width: 782px) {
    .admin-bar .site {
        min-height: calc(100vh - 46px);
    }
}

/* Main Container Logic
--------------------------------------------- */
.site-content {
    width: 100%;
}

/* The Container holding Main + Sidebar */
.site-content-inner {
    display: grid;
    gap: var(--kb-spacing-md);
    margin-top: var(--kb-spacing-md);
    margin-bottom: var(--kb-spacing-lg);
}

/* Default: Stacked (Mobile First) */
.site-content-inner {
    grid-template-columns: 1fr;
}

/* Tablet & Desktop: 2 Columns */
@media (min-width: 800px) {
    .site-content-inner {
        grid-template-columns: 2fr 1fr; 
        align-items: start;
    }
}

/* Standard Content Width (For non-block content) */
.wrapper, 
.site-header .inner, 
.site-footer .inner {
    max-width: var(--kb-width-wide);
    margin: 0 auto;
    padding: 0 var(--kb-spacing-sm);
}

/* Gutenberg Alignments
--------------------------------------------- */
.aligncenter {
    clear: both;
    display: block;
    margin-left: auto;
    margin-right: auto;
    margin-bottom: var(--kb-spacing-sm);
}

.alignwide {
    max-width: var(--kb-width-wide);
    margin-left: auto;
    margin-right: auto;
}

.alignfull {
    width: 100vw;
    max-width: 100vw;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
}

.alignleft {
    float: left;
    margin-right: 1.5em;
    margin-bottom: 1.5em;
}

.alignright {
    float: right;
    margin-left: 1.5em;
    margin-bottom: 1.5em;
}

/* Captions */
.wp-caption {
    margin-bottom: 1.5em;
    max-width: 100%;
}
.wp-caption-text {
    font-size: var(--wp--preset--font-size--small, 0.875rem);
    text-align: center;
    color: var(--wp--preset--color--secondary, #666);
    margin-top: 0.5rem;
}

/* Page & Full Width Logic
--------------------------------------------- */
.page .site-main,
.page .entry-content {
    max-width: 100%;
    margin: 0;
    padding: 0;
}
.entry-content > * {
    max-width: var(--kb-width-content);
    margin-left: auto;
    margin-right: auto;
}

/* Allow Wide blocks to break out */
.entry-content > .alignwide {
    max-width: var(--kb-width-wide);
}

/* Allow Full blocks to hit edges */
.entry-content > .alignfull {
    max-width: 100%;
}

/* Blank Canvas Template Overrides
--------------------------------------------- */
.page-template-template-blank {
    background-color: #fff;
}
.page-template-template-blank .site-main {
    margin-top: 0;
    margin-bottom: 0;
    padding-top: 0;
    padding-bottom: 0;
}
.page-template-template-blank .entry-content > *:first-child {
    margin-top: 0;
}

/*--------------------------------------------------------------
5. Components
--------------------------------------------------------------*/

/* Forms 
--------------------------------------------- */
input[type="text"],
input[type="email"],
input[type="url"],
input[type="password"],
input[type="search"],
textarea,
select {
    display: block;
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-family: inherit;
    font-size: 1rem;
    margin-bottom: 1rem;
}

input:focus, textarea:focus, select:focus {
    outline: 2px solid var(--wp--preset--color--primary, #0073aa);
    outline-offset: -2px;
}

button,
input[type="submit"] {
    display: inline-block;
    background-color: var(--wp--preset--color--primary, #0073aa);
    color: #fff;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s;
    text-decoration: none;
}

button:hover,
input[type="submit"]:hover {
    background-color: var(--wp--preset--color--contrast, #111);
    color: #fff;
}

/* Header & Navigation
--------------------------------------------- */
.site-header {
    padding: var(--kb-spacing-md) 0;
    background-color: var(--wp--preset--color--base);
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap; 
    gap: var(--kb-spacing-sm);
}

.site-branding {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.custom-logo-link {
    display: block;
    text-decoration: none;
    box-shadow: none;
}
.custom-logo-link img {
    max-width: 200px;
    height: auto;
    display: block;
}

.site-title {
    margin: 0;
    font-size: var(--wp--preset--font-size--large);
    font-weight: 700;
    line-height: 1.1;
}
.site-title a {
    text-decoration: none;
    color: var(--wp--preset--color--contrast);
}

.site-description {
    margin: 0;
    font-size: var(--wp--preset--font-size--small);
    color: var(--wp--preset--color--secondary);
    display: none;
}
@media (min-width: 768px) {
    .site-description {
        display: block;
    }
}

/* Navigation - General */
.main-navigation {
    margin-left: auto; 
    display: block;
}

.main-navigation ul {
    display: flex;
    flex-wrap: wrap;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 1.5rem;
}

.main-navigation li {
    position: relative;
}

.main-navigation a {
    display: block;
    text-decoration: none;
    font-weight: 500;
    color: var(--wp--preset--color--contrast);
}

/* Submenus (Desktop) */
.main-navigation ul ul {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--wp--preset--color--base);
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    min-width: 200px;
    flex-direction: column;
    gap: 0;
    z-index: 999;
    padding: 0.5rem 0;
}

.main-navigation ul li:hover > ul,
.main-navigation ul li:focus-within > ul {
    display: flex;
}

.main-navigation ul ul a {
    padding: 0.5rem 1rem;
    width:100%;
}
.main-navigation ul ul a:hover {
    background-color: #f5f5f5;
}

/* Navigation - Mobile Logic */
.menu-toggle {
    display: none;
}

@media screen and (max-width: 768px) {
    .menu-toggle {
        display: block;
        width: 100%;
        text-align: center;
        padding: 1rem;
        background: transparent;
        border: 1px solid var(--wp--preset--color--contrast);
        color: var(--wp--preset--color--contrast);
        font-size: 0.875rem;
        cursor: pointer;
    }

    .main-navigation ul {
        display: none;
        flex-direction: column;
        width: 100%;
        gap: 0;
        border-top: 1px solid #eee;
        margin-top: 1rem;
    }

    .main-navigation.toggled ul {
        display: flex;
    }

    .main-navigation ul li {
        border-bottom: 1px solid #eee;
        width: 100%;
        display:flex;
    }

    .main-navigation a {
        padding: 1rem 0;
    }

    .main-navigation ul ul {
        position: static;
        box-shadow: none;
        padding-left: 1rem;
        display: none;
    }
    
    .main-navigation.toggled ul ul {
        display: block; 
    }
    .main-navigation ul li.menu-item-has-children {
        display:block;
    }
}

/* Content & Post Formatting
--------------------------------------------- */
.page-header {
    margin-bottom: var(--kb-spacing-md);
    border-bottom: 2px solid var(--wp--preset--color--primary);
    padding-bottom: 0.5rem;
}

.page-title {
    margin: 0;
}

.archive-description {
    margin-top: 0.5rem;
    font-size: 1.1rem;
    color: var(--wp--preset--color--secondary);
    max-width: 800px;
}

/* Post Cards (Archives) */
.blog .post, 
.archive .post, 
.search .post {
    background: #fff;
    border: 1px solid #eee;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: var(--kb-spacing-md);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.blog .post:hover, 
.archive .post:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.05);
}

.post-thumbnail img {
    width: 100%;
    height: 250px;
    object-fit: cover;
    display: block;
}

.entry-wrapper {
    padding: var(--kb-spacing-md);
}

.entry-title {
    margin-bottom: 0.5rem;
    font-size: var(--wp--preset--font-size--x-large);
    line-height: 1.3;
}
.entry-title a {
    text-decoration: none;
    color: var(--wp--preset--color--contrast);
}
.entry-title a:hover {
    color: var(--wp--preset--color--primary);
}

.entry-meta {
    font-size: var(--wp--preset--font-size--small);
    color: var(--wp--preset--color--secondary);
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Read More Button */
.read-more-wrapper {
    margin-top: 1.5rem;
}
.button.read-more {
    display: inline-block;
    background: transparent;
    border: 2px solid var(--wp--preset--color--primary);
    color: var(--wp--preset--color--primary);
    padding: 0.5rem 1.5rem;
    border-radius: 4px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s;
}
.button.read-more:hover {
    background: var(--wp--preset--color--primary);
    color: #fff;
}

/* Single Post Specifics */
.single .post {
    border: none;
    background: transparent;
    box-shadow: none;
    margin-bottom: 0;
    padding: 0;
}
.single .entry-wrapper {
    padding: 0;
}

/* Pagination */
.navigation.pagination {
    margin-top: var(--kb-spacing-lg);
    border-top: 1px solid #eee;
    padding-top: var(--kb-spacing-sm);
}
.nav-links {
    display: flex;
    justify-content: space-between;
}
.nav-links a {
    padding: 0.5rem 1rem;
    background: #f5f5f5;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 600;
}
.nav-links a:hover {
    background: var(--wp--preset--color--primary);
    color: #fff;
}

/* Single Post Navigation */
.post-navigation {
    margin: var(--kb-spacing-md) 0;
    padding: var(--kb-spacing-md) 0;
    border-top: 1px solid #eee;
    border-bottom: 1px solid #eee;
}
.post-navigation .nav-links {
    display: flex;
    justify-content: space-between;
    gap: var(--kb-spacing-md);
}
.post-navigation .nav-previous,
.post-navigation .nav-next {
    width: 50%;
}
.post-navigation .nav-next {
    text-align: right;
}
.post-navigation .nav-subtitle {
    display: block;
    font-size: var(--wp--preset--font-size--small);
    color: var(--wp--preset--color--secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}
.post-navigation .nav-title {
    font-weight: 700;
    color: var(--wp--preset--color--primary);
    font-size: 1.1rem;
}
.post-navigation a {
    text-decoration: none;
    display: block;
}
.post-navigation a:hover .nav-title {
    color: var(--wp--preset--color--contrast);
    text-decoration: underline;
}

/* Comments */
.comments-area {
    margin-top: var(--kb-spacing-lg);
}
.comments-title {
    font-size: var(--wp--preset--font-size--large);
    margin-bottom: var(--kb-spacing-md);
}
.comment-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.comment-body {
    margin-bottom: var(--kb-spacing-md);
    padding-bottom: var(--kb-spacing-md);
    border-bottom: 1px solid #eee;
}
.comment-meta {
    margin-bottom: 0.5rem;
    font-size: var(--wp--preset--font-size--small);
}
.comment-author .fn {
    font-weight: 700;
    font-style: normal;
    margin-right: 0.5rem;
}

/* Sidebar & Widgets 
--------------------------------------------- */
#secondary {
    font-size: var(--wp--preset--font-size--small, 0.9rem);
    color: var(--wp--preset--color--secondary, #666);
}

.widget {
    margin-bottom: var(--kb-spacing-md);
    padding-bottom: var(--kb-spacing-md);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}
.widget:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.widget-title {
    font-size: var(--wp--preset--font-size--medium, 1.1rem);
    font-weight: 700;
    margin-bottom: var(--kb-spacing-sm);
    color: var(--wp--preset--color--contrast, #111);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.widget ul {
    list-style: none;
    margin: 0;
    padding: 0;
}
.widget ul li {
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.widget ul li:last-child {
    border-bottom: none;
}

.widget a {
    text-decoration: none;
    color: var(--wp--preset--color--secondary);
    transition: color 0.2s ease;
}
.widget a:hover {
    color: var(--wp--preset--color--primary);
    padding-left: 5px;
}
.wp-block-search__button {
    margin-left: 0.5rem;
}

/* Footer 
--------------------------------------------- */
.site-footer {
    background-color: var(--wp--preset--color--contrast, #111);
    color: var(--wp--preset--color--base, #fff);
    padding: var(--kb-spacing-md) 0;
    font-size: var(--wp--preset--font-size--small);
    margin-top: auto; /* Sticky footer magic */
}

.footer-inner {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: var(--kb-spacing-sm);
}

.site-footer a {
    color: var(--wp--preset--color--base);
    opacity: 0.8;
    text-decoration: none;
}
.site-footer a:hover {
    opacity: 1;
    text-decoration: underline;
}

.copyright-text {
    margin: 0;
    opacity: 0.7;
}
@media (max-width: 600px) {
    .footer-inner {
        flex-direction: column;
        text-align: center;
    }
}

/*--------------------------------------------------------------
6. Utilities & Accessibility
--------------------------------------------------------------*/

/* Screen Readers */
.screen-reader-text {
    border: 0;
    clip: rect(1px, 1px, 1px, 1px);
    clip-path: inset(50%);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute !important;
    width: 1px;
    word-wrap: normal !important;
}
.screen-reader-text:focus {
    background-color: #f1f1f1;
    border-radius: 3px;
    box-shadow: 0 0 2px 2px rgba(0, 0, 0, 0.6);
    clip: auto !important;
    clip-path: none;
    color: #21759b;
    display: block;
    font-size: 0.875rem;
    font-weight: 700;
    height: auto;
    left: 5px;
    line-height: normal;
    padding: 15px 23px 14px;
    text-decoration: none;
    top: 5px;
    width: auto;
    z-index: 100000;
}

/* 404 Error Page */
.error-404 {
    text-align: center;
    padding: var(--kb-spacing-lg) 0;
}
.error-404 .page-title {
    font-size: 3rem;
    color: var(--wp--preset--color--primary);
    margin-bottom: var(--kb-spacing-md);
}
.error-404 .page-content p {
    font-size: 1.25rem;
    margin-bottom: var(--kb-spacing-md);
    color: var(--wp--preset--color--secondary);
}
.error-search-form {
    max-width: 500px;
    margin: 0 auto var(--kb-spacing-md);
}
.error-search-form .search-form {
    display: flex;
    gap: 0.5rem;
}
.error-search-form .search-field {
    margin-bottom: 0;
}
.error-actions {
    margin-top: var(--kb-spacing-md);
}
.error-actions .button {
    padding: 1rem 2rem;
    font-size: 1.1rem;
}

/* No Results / Empty State */
.no-results {
    text-align: center;
    padding: var(--kb-spacing-lg) var(--kb-spacing-md);
    background: #f9f9f9;
    border-radius: 8px;
    border: 1px dashed #ccc;
    margin-bottom: var(--kb-spacing-lg);
}
.no-results .page-title {
    color: var(--wp--preset--color--secondary);
    font-size: 2rem;
    margin-bottom: 1rem;
}
.no-results .page-content p {
    font-size: 1.1rem;
    margin-bottom: 2rem;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

/*--------------------------------------------------------------
# Utility Classes: Reverse Mobile Columns
# Apply 'reverse-mobile' to the parent Columns block.
--------------------------------------------------------------*/

@media (max-width: 781px) {
    /* Target the columns container when it has our custom class */
    .wp-block-columns.reverse-mobile {
        display: flex;
        flex-direction: column-reverse !important;
    }
}