/*
Theme Name: DI Zinios Theme
Theme URI: https://dizinios.lt
Author: CTO Agent
Description: Custom clean theme for DI Zinios - Lithuanian AI news portal. Minimalist white design with colored category badges, 3-column grid, newsletter signup.
Template: ai-magazine
Version: 1.5.0
Requires at least: 6.0
Tested up to: 6.8
Requires PHP: 7.4
License: GPLv3 or later
Text Domain: dizinios-theme
*/

/* ============================
   GLOBAL STYLES
   ============================ */

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    color: #1a1a1a;
    background: #ffffff;
    line-height: 1.6;
}

/* ============================
   HEADER
   ============================ */

.site-header {
    border-bottom: 1px solid #f0f0f0;
    padding: 16px 0;
    background: #ffffff;
    position: sticky;
    top: 0;
    z-index: 100;
}

.site-header .wp-block-navigation a {
    font-size: 15px;
    font-weight: 500;
    color: #333;
    text-decoration: none;
    transition: color 0.2s;
}

/* Navigation items spacing — ensure gap between menu items */
.site-header .wp-block-navigation .wp-block-navigation-item {
    margin-right: 24px !important;
}
.site-header .wp-block-navigation .wp-block-navigation-item:last-child {
    margin-right: 0 !important;
}

/* Fix navigation flex layout gap */
.site-header .wp-block-navigation__container,
.site-header .wp-block-navigation ul {
    gap: 28px !important;
}

/* Search — modern pill style */
.site-header .wp-block-search {
    gap: 0 !important;
}
.site-header .wp-block-search__inside-wrapper {
    background: #f5f5f5 !important;
    border: 1px solid #e8e8e8 !important;
    border-radius: 24px !important;
    padding: 4px 4px 4px 16px !important;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.site-header .wp-block-search__inside-wrapper:focus-within {
    border-color: #1a73e8 !important;
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.12) !important;
    background: #fff !important;
}
.site-header .wp-block-search__input {
    background: transparent !important;
    border: none !important;
    font-size: 14px !important;
    color: #333 !important;
    padding: 6px 0 !important;
    outline: none !important;
    min-width: 160px !important;
}
.site-header .wp-block-search__input::placeholder {
    color: #999 !important;
}
.site-header .wp-block-search__button {
    background: #1a73e8 !important;
    border: none !important;
    color: #fff !important;
    padding: 6px 10px !important;
    min-width: auto !important;
    cursor: pointer;
    border-radius: 20px !important;
    transition: background 0.2s;
}
.site-header .wp-block-search__button:hover {
    background: #1557b0 !important;
}
.site-header .wp-block-search__button svg {
    fill: currentColor !important;
    width: 16px !important;
    height: 16px !important;
}

.site-header .wp-block-navigation a:hover {
    color: #1a73e8;
}

.site-header .wp-block-site-title a {
    text-decoration: none;
    font-family: 'Montserrat', 'Inter', sans-serif;
    font-weight: 700;
    font-size: 18px;
    color: #1a1a1a;
    letter-spacing: -0.3px;
}

/* ============================
   HERO SECTION
   ============================ */

.hero-section {
    padding: 60px 0 40px;
    border-bottom: 1px solid #f0f0f0;
}

.hero-headline {
    font-size: clamp(32px, 5vw, 48px);
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -1px;
    color: #1a1a1a;
    margin-bottom: 12px;
}

.hero-subtitle {
    font-size: 18px;
    color: #666;
    font-weight: 400;
    line-height: 1.5;
}

/* ============================
   CATEGORY BADGES
   ============================ */

.wp-block-post-terms a,
.category-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-decoration: none !important;
    line-height: 1.4;
}

/* Category color mapping */
.cat-praktinis-ai a, .badge-praktinis { background: #e8f5e9; color: #2e7d32 !important; }
.cat-verslas-ir-ai a, .badge-verslas { background: #fff3e0; color: #e65100 !important; }
.cat-modeliai a, .badge-modeliai { background: #f3e5f5; color: #7b1fa2 !important; }
.cat-etika a, .badge-etika { background: #ffebee; color: #c62828 !important; }
.cat-mokslas a, .badge-mokslas { background: #e3f2fd; color: #1565c0 !important; }
.cat-naujienos a, .badge-naujienos { background: #f5f5f5; color: #616161 !important; }

/* Default badge */
.wp-block-post-terms a {
    background: #f0f4ff;
    color: #1a73e8 !important;
    margin-right: 6px;
    margin-bottom: 6px;
}

/* ============================
   ARTICLE CARDS / GRID
   ============================ */

/* Force grid layout on post templates */
.wp-block-post-template.is-layout-grid {
    display: grid !important;
    gap: 28px !important;
}

.wp-block-post-template.is-layout-grid.columns-3 {
    grid-template-columns: repeat(3, 1fr) !important;
}

/* Each card in the grid */
.wp-block-post-template .wp-block-post {
    background: #ffffff;
    border-radius: 12px;
    overflow: hidden;
    transition: box-shadow 0.3s ease, transform 0.2s ease;
    border: 1px solid #f0f0f0;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.wp-block-post-template .wp-block-post:hover {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

/* Card inner group — flex column with proper spacing */
.wp-block-post-template .wp-block-post > .wp-block-group {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    height: 100%;
}

/* Featured image container — fixed aspect ratio, no shrink */
.wp-block-post-template .wp-block-post-featured-image {
    aspect-ratio: 16/9 !important;
    overflow: hidden !important;
    border-radius: 8px !important;
    flex-shrink: 0 !important;
    width: 100% !important;
    position: relative !important;
}

.wp-block-post-template .wp-block-post-featured-image img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    display: block !important;
    transition: transform 0.3s ease;
}

.wp-block-post-template .wp-block-post:hover .wp-block-post-featured-image img {
    transform: scale(1.03);
}

/* Post title — clear block, proper spacing */
.wp-block-post-template .wp-block-post-title {
    font-size: 18px !important;
    font-weight: 700 !important;
    line-height: 1.35 !important;
    margin: 0 !important;
    padding: 0 !important;
    display: block !important;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.wp-block-post-template .wp-block-post-title a {
    color: #1a1a1a;
    text-decoration: none;
}

.wp-block-post-template .wp-block-post-title a:hover {
    color: #1a73e8;
}

/* Category terms — inline, no overlap */
.wp-block-post-template .wp-block-post-terms {
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    line-height: 1.4 !important;
}

/* Excerpt */
.wp-block-post-template .wp-block-post-excerpt {
    font-size: 14px;
    color: #666;
    line-height: 1.5;
    margin: 0 !important;
}

/* Date */
.wp-block-post-template .wp-block-post-date {
    font-size: 13px;
    color: #999;
    margin: 0 !important;
}

/* Meta group (date + author) */
.wp-block-post-template .wp-block-post .wp-block-group.is-layout-flex {
    gap: 8px !important;
    flex-wrap: wrap !important;
}

/* Reading time style */
.reading-time {
    font-size: 13px;
    color: #999;
}

/* ============================
   FEATURED POST (HERO CARD)
   ============================ */

.featured-post {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    align-items: center;
    padding: 40px 0;
}

.featured-post .featured-image {
    border-radius: 12px;
    overflow: hidden;
    aspect-ratio: 16/10;
}

.featured-post .featured-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.featured-post .featured-content .wp-block-post-title {
    font-size: 28px;
    font-weight: 800;
    line-height: 1.25;
}

@media (max-width: 768px) {
    .featured-post {
        grid-template-columns: 1fr;
        gap: 24px;
    }
}

/* ============================
   FOOTER
   ============================ */

.site-footer {
    background: #fafafa;
    border-top: 1px solid #f0f0f0;
    padding: 60px 0 30px;
    margin-top: 60px;
}

.site-footer .footer-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr 1.5fr;
    gap: 40px;
}

.site-footer .footer-logo {
    font-size: 22px;
    font-weight: 800;
    color: #1a1a1a;
    margin-bottom: 12px;
}

.site-footer .footer-description {
    font-size: 14px;
    color: #666;
    line-height: 1.6;
}

.site-footer h4 {
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #1a1a1a;
    margin-bottom: 16px;
}

.site-footer .footer-nav a {
    display: block;
    font-size: 14px;
    color: #666;
    text-decoration: none;
    padding: 4px 0;
    transition: color 0.2s;
}

.site-footer .footer-nav a:hover {
    color: #1a73e8;
}

/* Newsletter form */
.newsletter-form {
    display: flex;
    gap: 8px;
}

.newsletter-form input[type="email"] {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.newsletter-form input[type="email"]:focus {
    border-color: #1a73e8;
}

.newsletter-form button {
    padding: 10px 20px;
    background: #1a73e8;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.newsletter-form button:hover {
    background: #1557b0;
}

.footer-bottom {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: #999;
}

.footer-bottom a {
    color: #999;
    text-decoration: none;
}

.footer-bottom a:hover {
    color: #1a73e8;
}

@media (max-width: 768px) {
    .site-footer .footer-grid {
        grid-template-columns: 1fr;
        gap: 30px;
    }

    .footer-bottom {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
}

/* ============================
   SINGLE POST
   ============================ */

.single-post-content {
    max-width: 720px;
    margin: 0 auto;
}

.single-post-content h1 {
    font-size: clamp(28px, 4vw, 42px);
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -0.5px;
}

/* ============================
   SEARCH OVERLAY
   ============================ */

.search-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    color: #333;
}

/* ============================
   DARK MODE (optional toggle)
   ============================ */

body.dark-mode {
    background: #1a1a1a;
    color: #e0e0e0;
}

body.dark-mode .site-header {
    background: #1a1a1a;
    border-color: #333;
}

body.dark-mode .articles-grid .wp-block-post {
    background: #2a2a2a;
    border-color: #333;
}

body.dark-mode .site-footer {
    background: #111;
    border-color: #333;
}

/* ============================
   PARENT THEME RESET — ai-magazine overrides
   ============================ */

/* Reset all parent theme positioning that causes overlap */
.wp-site-blocks > * {
    position: relative;
    z-index: 1;
}

/* Force all blocks to have proper box model */
.wp-site-blocks *,
.wp-site-blocks *::before,
.wp-site-blocks *::after {
    box-sizing: border-box;
}

/* Reset parent theme's absolute/fixed positioning on content blocks */
.wp-site-blocks .wp-block-group,
.wp-site-blocks .wp-block-query,
.wp-site-blocks .wp-block-post-template,
.wp-site-blocks .wp-block-columns {
    position: relative;
    float: none;
    clear: both;
}

/* Ensure proper spacing between major sections */
main.wp-block-group > .wp-block-group,
main.wp-block-group > .wp-block-separator {
    margin-top: 0;
    margin-bottom: 0;
}

/* CRITICAL: Override parent theme's grid/flex breakage */
.wp-block-post-template.is-layout-grid {
    display: grid !important;
    list-style: none !important;
    padding: 0 !important;
    margin: 0 !important;
}

/* Prevent parent theme from overriding card layout */
.wp-block-post-template .wp-block-post > .wp-block-group[class*="is-layout"] {
    display: flex !important;
    flex-direction: column !important;
}

/* Override any parent theme negative margins on images */
.wp-block-post-template .wp-block-post-featured-image {
    margin: 0 !important;
}

/* Override parent theme margin on post titles inside cards */
.wp-block-post-template .wp-block-post .wp-block-post-title {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}

/* Override parent theme margin on post terms inside cards */
.wp-block-post-template .wp-block-post .wp-block-post-terms {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}

/* ============================
   HEADER — STICKY + LOGO
   ============================ */

.site-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: #ffffff !important;
}

/* Logo display — always visible */
.site-header .wp-block-site-logo {
    flex-shrink: 0;
    display: inline-block !important;
}

.site-header .wp-block-site-logo img {
    height: 40px;
    width: auto;
    object-fit: contain;
    display: block !important;
}

/* Site title next to logo */
.site-header .wp-block-site-title {
    display: inline-block !important;
}

/* ============================
   HERO SECTION — SPACING
   ============================ */

.hero-section {
    position: relative;
    z-index: 1;
    overflow: hidden;
}

/* ============================
   SECTION SPACING
   ============================ */

/* Proper spacing between homepage sections */
main.wp-block-group > .wp-block-group {
    position: relative;
    z-index: 1;
    overflow: visible;
}

/* Section headings — spacing */
.wp-block-query + .wp-block-query,
.wp-block-heading + .wp-block-query {
    margin-top: 16px;
}

/* ============================
   FOOTER — ALWAYS VISIBLE
   ============================ */

.site-footer {
    display: block !important;
    visibility: visible !important;
    position: relative;
    z-index: 1;
    clear: both;
}

/* Footer columns — ensure proper layout */
.site-footer .wp-block-columns {
    display: flex !important;
}

/* Footer navigation links */
.site-footer .wp-block-navigation-item__content {
    color: #666;
    text-decoration: none;
    font-size: 14px;
    padding: 4px 0;
    display: block;
}

.site-footer .wp-block-navigation-item__content:hover {
    color: #1a73e8;
}

/* ============================
   UTILITY
   ============================ */

.section-title {
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #999;
    margin-bottom: 24px;
}

.divider {
    border: none;
    border-top: 1px solid #f0f0f0;
    margin: 40px 0;
}

/* Article count info */
.article-count {
    font-size: 14px;
    color: #999;
    margin-bottom: 24px;
}

/* ============================
   RESPONSIVE — TABLET (≤1024px)
   ============================ */

@media (max-width: 1024px) {
    .wp-block-post-template.is-layout-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 16px !important;
    }
}

/* ============================
   MOBILE — DELFI STYLE (≤768px)
   ============================ */

/* Navigation overlay mobile styling */
.wp-block-navigation__responsive-container.is-menu-open {
    background: #ffffff !important;
}

.wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-item__content {
    font-size: 18px;
    font-weight: 600;
    padding: 8px 0;
}

/* Prevent horizontal overflow */
html, body {
    overflow-x: hidden;
}

@media (max-width: 768px) {

    /* --- HEADER: Compact 50px like Delfi --- */
    .site-header {
        padding: 8px 0 !important;
    }

    .site-header.has-background {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    .site-header .wp-block-site-title a {
        font-size: 20px;
    }

    .site-header .wp-block-search {
        width: auto;
    }

    .site-header .wp-block-search__input {
        width: 100px;
        padding: 6px 10px;
        font-size: 13px;
    }

    /* --- HERO: Stack vertically, image on top --- */
    .hero-section {
        padding: 20px 0 16px !important;
    }

    .hero-section.has-background {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    .hero-headline {
        font-size: 24px !important;
        letter-spacing: -0.5px;
        margin-bottom: 8px;
    }

    .hero-subtitle {
        font-size: 15px;
        margin-bottom: 16px;
    }

    /* Stack hero columns — image first (reverse order so featured post appears on top) */
    .hero-section .wp-block-columns {
        flex-wrap: wrap !important;
        flex-direction: column-reverse !important;
        gap: 16px !important;
    }

    .hero-section .wp-block-columns > .wp-block-column {
        flex-basis: 100% !important;
        width: 100% !important;
    }

    /* Hero featured image — full width, 16:9 ratio like Delfi */
    .hero-section .wp-block-post-featured-image {
        border-radius: 8px !important;
        aspect-ratio: 16/9;
        height: auto !important;
    }

    .hero-section .wp-block-post-featured-image img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    /* Hero featured post title */
    .hero-section .wp-block-post-title {
        font-size: 18px !important;
    }

    /* --- ARTICLES GRID: 2 columns on mobile --- */
    .wp-block-post-template.is-layout-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
    }

    /* --- ARTICLE CARDS: Clean, borderless on mobile --- */
    .wp-block-post-template .wp-block-post {
        border: none !important;
        border-radius: 0 !important;
        background: transparent !important;
    }

    .wp-block-post-template .wp-block-post:hover {
        box-shadow: none;
        transform: none;
    }

    /* Card inner group — tighter gap on mobile */
    .wp-block-post-template .wp-block-post > .wp-block-group {
        gap: 6px !important;
    }

    /* Smaller titles on mobile */
    .wp-block-post-template .wp-block-post-title {
        font-size: 14px !important;
        line-height: 1.3 !important;
    }

    /* Category labels — small colored text, no background */
    .wp-block-post-template .wp-block-post-terms a {
        font-size: 10px !important;
        padding: 0 !important;
        background: none !important;
        font-weight: 600;
    }

    /* Hide excerpt on mobile — save space */
    .wp-block-post-template .wp-block-post-excerpt {
        display: none !important;
    }

    /* Meta info smaller */
    .wp-block-post-template .wp-block-post-date,
    .wp-block-post-template .reading-time {
        font-size: 11px !important;
    }

    /* Section title */
    .section-title {
        font-size: 12px !important;
        margin-bottom: 16px !important;
    }

    /* --- FOOTER: Stack vertically --- */
    .site-footer {
        padding: 32px 0 16px !important;
        margin-top: 32px !important;
    }

    .site-footer.has-background {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    .site-footer .wp-block-columns {
        flex-wrap: wrap !important;
        flex-direction: column !important;
        gap: 24px !important;
    }

    .site-footer .wp-block-columns > .wp-block-column {
        flex-basis: 100% !important;
        width: 100% !important;
    }

    .footer-bottom {
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }

    /* Newsletter form stack */
    .newsletter-form {
        flex-direction: column;
    }

    .newsletter-form button {
        width: 100%;
    }
}

/* ============================
   MOBILE — SMALL PHONES (≤480px)
   ============================ */

@media (max-width: 480px) {

    .site-header .wp-block-site-title a {
        font-size: 18px;
    }

    /* Hide search input, keep icon */
    .site-header .wp-block-search__input {
        width: 0;
        padding: 0;
        border: none;
        opacity: 0;
    }

    .hero-headline {
        font-size: 22px !important;
    }

    .hero-subtitle {
        font-size: 14px;
    }

    /* Even tighter grid gap */
    .wp-block-post-template.is-layout-grid {
        gap: 8px !important;
    }

    .wp-block-post-template .wp-block-post-title {
        font-size: 13px !important;
    }

    .wp-block-post-template .wp-block-post-terms a {
        font-size: 9px !important;
    }

    /* Hide meta on very small screens */
    .wp-block-post-template .wp-block-post-date {
        display: none !important;
    }
}
